0.2.1 • Published 1 year ago
@suchipi/error-utils v0.2.1
@suchipi/error-utils
Node.js utils for parsing error stacks, applying source maps to error stacks, etc
ParsedErrorclass- can be constructed from an Error instance
- stack lines are parsed into a data structure with filename/line/column info
- can be manipulated and then converted back into a normal Error
- has a
stackproperty getter which makes a V8-style stack string from the parsed stack frames
applySourceMapsToParsedErrorfunction- updates the line/column numbers on the stack frames of a ParsedError by using source maps
- returns a new ParsedError
applySourceMapsToStackFramefunction- same as above but for a single StackFrame
getStackFramefunction- given a stack offset number, gets a
StackFrameinstance from the current callstack. - offset of
0gives the call togetStackFrame. - can be used to obtain the file name and (sometimes) function name of the currently-executing file, or one of its callers.
- given a stack offset number, gets a
isErrorfunction- type predicate function
- returns true for objects with shape
{ name: string, message: string }whennameends with "Error"