{"repo":"ehmicky/merge-error-cause","free":true,"listed":false,"github":"https://github.com/ehmicky/merge-error-cause","clone":"git clone https://github.com/ehmicky/merge-error-cause.git","description":"Merge an error with its `cause`","language":"JavaScript","stars":12,"topics":["browser","cause","code-quality","error","error-handler","error-handling","error-monitoring","error-reporting","errors","exceptions"],"license":"MIT","category":"dev-tools","readme_excerpt":"Merge an error with its cause . This merges error.cause recursively with its parent error , including its message , stack , name and errors . Example Install This package works in both Node.js =18.18.0 and browsers. This is an ES module. It must be loaded using an import or import() statement, not require() . If TypeScript is used, it must be configured to output ES modules, not CommonJS. API mergeErrorCause(error) error Error any \\ Return value : Error error is modified and returned. If error 's class is Error or if error.wrap is true , error.cause is modified and returned instead. If error is not a valid Error , a new error is created and returned instead. This never throws. Background error.cause is a recent JavaScript feature to wrap error messages and properties. However, it comes with a few issues. Traversing error.cause Problem Consumers need to traverse error.cause . This is tricky to get right. For example: - error.cause.cause might also exist (and so on) - If error is not an Error instance, error.name might throw - Recursing over error.cause might be an infinite cycle Solution This library merges error.cause recursively. It also ensures error is an Error instance. Consumers can then handle errors without checking its cause . Verbose stack trace Problem Stack traces with multiple error.cause can be quite verbose. Each error cause is indented and printed separately. - The stack traces mostly repeat each other since the function calls are part of the same line executio","default_branch":null,"files":null,"tree":[],"storefront":"/r/ehmicky","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/ehmicky/merge-error-cause/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}