Skip to content

Commit 31c6a87

Browse files
committed
chore: add JSDoc comments to infra/errors.ts 2026-06-17
1 parent 5bc6758 commit 31c6a87

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/infra/errors.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1+
/** Error names commonly thrown by prompt libraries when the user presses Ctrl+C. */
12
const PROMPT_ABORT_ERROR_NAMES = new Set([
23
'ExitPromptError',
34
'AbortPromptError',
45
'PromptAbortError',
56
]);
67

8+
/** Thrown when the user explicitly cancels a command (e.g. via Ctrl+C or a confirmation prompt). */
79
export class UserCancelledError extends Error {
810
constructor(message: string = 'User cancelled the current command.') {
911
super(message);
1012
this.name = 'UserCancelledError';
1113
}
1214
}
1315

16+
/** Return `true` when `error` is a prompt-library abort (e.g. user pressed Escape or Ctrl+C). */
1417
export function isPromptAbortError(error: unknown): boolean {
1518
if (!(error instanceof Error)) {
1619
return false;
@@ -23,10 +26,12 @@ export function isPromptAbortError(error: unknown): boolean {
2326
return /force closed the prompt|prompt was canceled|canceled prompt/i.test(error.message);
2427
}
2528

29+
/** Return `true` when `error` represents a user-initiated cancellation. */
2630
export function isUserCancelledError(error: unknown): boolean {
2731
return error instanceof UserCancelledError || isPromptAbortError(error);
2832
}
2933

34+
/** Safely extract a human-readable message from an unknown thrown value. */
3035
export function getErrorMessage(
3136
error: unknown,
3237
fallback: string = 'Something went wrong. Please try again.',

0 commit comments

Comments
 (0)