node-parsetrace
Minimal library for parsing and printing node stacktrace. Mostly for use in express-error-with-sources.
Installation
npm install --save parsetrace
Example
var parsetrace = ; try throw 'My cool error'; catch e console;
API
parsetrace(error, [options], [callback])
Parses stack trace from Error
, string
or object
, that have .stack
and .message
property.
If callback is passed - all source code fetching will be async and error will be passed to it (even if strict
is true
).
;
Options:
sources
- fetch source code from files, that are mentioned in stacktrace. If file can not be found or readed - sources will be fetched silently (unless you enabledstrict
option) (default:false
)strict
- throws errors, while parsing stacktrace and fetching source code (default:false
)contextSize
- number of lines before and after the error line (default:3
)
Returns Object
with methods described below:
json()
Returns stacktrace as Json string
object()
Format of object you can see in json()
section.
Returns stacktrace as Object
toString([options])
Options:
excludeSources
- if stacktrace was parsed with sources, this will exclude them from output (default:false
)
Returns stacktrace as NodeJS formatted stacktracke string.