MCPcopy Create free account
hub / github.com/vercel/vercel / errorHandler

Function errorHandler

api/_lib/util/error-handler.ts:24–50  ·  view source on GitHub ↗
(error: Error, extras?: { [key: string]: any })

Source from the content-addressed store, hash-verified

22}
23
24export function errorHandler(error: Error, extras?: { [key: string]: any }) {
25 console.error(error);
26
27 if (!process.env.SENTRY_DSN) {
28 console.log(
29 'Skipping Sentry error reporting because SENTRY_DSN is not set'
30 );
31 return;
32 }
33
34 initSentry();
35
36 try {
37 withScope(scope => {
38 scope.setTag('service', serviceName);
39 scope.setTag('function_name', assertEnv('AWS_LAMBDA_FUNCTION_NAME'));
40
41 for (const [k, v] of Object.entries(extras)) {
42 scope.setExtra(k, v);
43 }
44
45 captureException(error);
46 });
47 } catch (e) {
48 console.error(`Failed to report error to Sentry: ${e}`);
49 }
50}

Callers 1

withApiHandlerFunction · 0.90

Calls 4

assertEnvFunction · 0.90
initSentryFunction · 0.85
errorMethod · 0.80
logMethod · 0.45

Tested by

no test coverage detected