TraceError
npm install trace-error --save
; globalTraceError = TraceError; // expose globally (optional) async { try await ; catche console; };
Output
TraceError: Failed to fetch content at _construct at TraceError.Exception at new TraceError at .../TraceError.js/tests/throw-test.js:159:19 at Object.<anonymous> ReferenceError: fetch is not defined at .../TraceError.js/tests/throw-test.js:157:5 at Object.<anonymous> at Module._compile at Object.Module._extensions..js at Module.load
Compatibility
Node >= 4.0; not tested on browsers
Functions
TraceError#cause(index = 0)
Get the cause at the specified index
TraceError#causes()
Get a list of all the causes
TraceError@stack
Get the long stack (base error with chained cause errors)
TraceError@messages
Get a list of all the messages
static TraceError@globalStackProperty
Attribute used to aggregate the long stack. Can be further customized via. inheritance and/or prototype modification
static TraceError@indent
Spaces used to indent long stack
More Detailed Examples
More detailed examples are in the /tests
folder
ES5/6 Cross-compatibility
Extend the TraceError as such in order to maximize compatibility with ES5; additionally, override the toJSON
as necessary
{ super...args; // not ideal Object; }