UNPKG

foxts

Version:

Opinionated collection of common TypeScript utils by @SukkaW

2 lines (1 loc) 450 B
function e(e){return"object"==typeof e&&null!==e&&"name"in e&&"string"==typeof e.name&&"message"in e&&"string"==typeof e.message&&(!("stack"in e)||"string"==typeof e.stack)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.extractErrorMessage=function(t,r=!0,n=!1){if(!e(t))return null;let s="";return r&&(s+=t.name,s+=": "),s+=t.message,n&&"stack"in t&&"string"==typeof t.stack&&(s+="\n"+t.stack),s.trim()},exports.isErrorLikeObject=e;