MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / reportApiError

Function reportApiError

packages/cli/src/cloud/errors.ts:51–89  ·  view source on GitHub ↗
(
  stage: string,
  err: unknown,
  options: {
    notFound?: string;
    extraHints?: Record<string, string>;
    suggestion?: string;
  } = {},
)

Source from the content-addressed store, hash-verified

49 */
50// fallow-ignore-next-line complexity
51export function reportApiError(
52 stage: string,
53 err: unknown,
54 options: {
55 notFound?: string;
56 extraHints?: Record<string, string>;
57 suggestion?: string;
58 } = {},
59): never {
60 const hints = { ...ERROR_CODE_HINTS, ...options.extraHints };
61 if (err instanceof HyperframesApiError) {
62 if (err.status === 404 && options.notFound) {
63 errorBox("Not found", options.notFound);
64 process.exit(1);
65 }
66 const hint = err.code ? hints[err.code] : undefined;
67 const title = `${stage} (HTTP ${err.status})`;
68 // Priority: code-specific hint > caller suggestion > bare code
69 // label > no third line. Code-specific hints win because they
70 // address the specific failure mode; the caller suggestion is a
71 // generic-context fallback.
72 if (hint) {
73 errorBox(title, err.message, hint);
74 } else if (options.suggestion) {
75 errorBox(title, err.message, options.suggestion);
76 } else if (err.code) {
77 errorBox(title, err.message, `code: ${err.code}`);
78 } else {
79 errorBox(title, err.message);
80 }
81 process.exit(1);
82 }
83 if (err instanceof Error) {
84 errorBox(stage, err.message, options.suggestion);
85 process.exit(1);
86 }
87 errorBox(stage, String(err), options.suggestion);
88 process.exit(1);
89}

Callers 7

errors.test.tsFile · 0.85
maybeUploadProjectFunction · 0.85
submitRenderFunction · 0.85
pollWithProgressFunction · 0.85
runFunction · 0.85
runFunction · 0.85
runFunction · 0.85

Calls 1

errorBoxFunction · 0.85

Tested by

no test coverage detected