UNPKG

@metamask/kernel-errors

Version:
1 lines 667 B
{"version":3,"file":"toError.mjs","sourceRoot":"","sources":["../../src/utils/toError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,OAAO,OAAO,YAAY,KAAK;QAC7B,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/**\n * Coerce an unknown problem into an Error object.\n *\n * @param problem - Whatever was caught.\n * @returns The problem if it is an Error, or a new Error with the problem as the cause.\n */\nexport function toError(problem: unknown): Error {\n return problem instanceof Error\n ? problem\n : new Error('Unknown', { cause: problem });\n}\n"]}