@metamask/multichain-account-service
Version:
Service to manage multichain accounts
1 lines • 2.06 kB
Source Map (JSON)
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qBAAiB;AACtC,OAAO,EACL,8BAA8B,EAC9B,cAAc,EACf,8BAA0B;AAC3B,OAAO,EAAE,iBAAiB,EAAE,oBAAgB;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CACzB,SAAwD,EACxD,OAAe,EACf,KAAc,EACd,OAAiC;IAEjC,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,8BAA8B,CAAC,KAAK,CAAC,EAAE,CAAC;QACnE,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACnC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACpC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAE9B,MAAM,WAAW,GAAG,iBAAiB,CAAC,OAAO,EAAE,KAAc,EAAE,OAAO,CAAC,CAAC;QACxE,SAAS,CAAC,gBAAgB,EAAE,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["import { logErrorAs } from './logger';\nimport {\n isKeyringControllerLockedError,\n isTimeoutError,\n} from './providers/utils';\nimport { createSentryError } from './utils';\n\n/**\n * Reports an error by logging it and optionally capturing it in Sentry.\n *\n * Timeout errors are treated as warnings (not reported to Sentry). All other\n * errors are logged as errors and captured via `captureException`.\n *\n * @param messenger - Object with an optional `captureException` method.\n * @param messenger.captureException - Optional method to capture exceptions in Sentry.\n * @param message - The static message describing what failed.\n * @param error - The caught error.\n * @param context - Optional context to attach to the Sentry error.\n */\nexport function reportError(\n messenger: { captureException?: (error: Error) => void },\n message: string,\n error: unknown,\n context?: Record<string, unknown>,\n): void {\n if (isTimeoutError(error) || isKeyringControllerLockedError(error)) {\n logErrorAs('warn', message, error);\n console.warn(message, error);\n } else {\n logErrorAs('error', message, error);\n console.error(message, error);\n\n const sentryError = createSentryError(message, error as Error, context);\n messenger.captureException?.(sentryError);\n }\n}\n"]}