mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-05 04:09:31 +08:00
12 lines
299 B
Text
12 lines
299 B
Text
/**
|
|
* @param {unknown} err
|
|
* @return {Error}
|
|
*/
|
|
function coalesce_to_error(err) {
|
|
return err instanceof Error ||
|
|
(err && /** @type {any} */ (err).name && /** @type {any} */ (err).message)
|
|
? /** @type {Error} */ (err)
|
|
: new Error(JSON.stringify(err));
|
|
}
|
|
|
|
export { coalesce_to_error as c };
|