Convert errors to/from plain objects.
MIT License
beforeSerialize(errorInstance)
and afterSerialize(errorInstance, errorObject)
options have been removed. Please use the transformObject(errorObject, errorInstance)
new option instead.serialize(error, {
- beforeSerialize: (error) => {
- error.date = error.date.toString()
- },
- afterSerialize: (error, errorObject) => {
- error.date = new Date(error.date)
- },
+ transformObject: (errorObject, error) => {
+ errorObject.date = errorObject.date.toString()
+ },
})
beforeParse(errorObject)
and afterParse(errorObject, errorInstance)
options have been removed. Please use the transformInstance(errorInstance, errorObject)
new option instead.parse(errorObject, {
- beforeParse: (errorObject) => {
- errorObject.date = new Date(errorObject.date)
- },
- afterParse: (errorObject, error) => {
- errorObject.date = errorObject.date.toString()
- },
+ transformInstance: (error, errorObject) => {
+ error.date = new Date(error.date)
+ },
})
include
and exclude
options to pick/omit specific properties. For example, this can be used to omit error additional properties or stack trace.transformArgs(constructorArgs)
option to transform an error message during parse(errorObject)
.errorObject
passed to parse(errorObject)
previously required the name
, message
and stack
properties. Only the message
property is now required. In other words, parse({message})
now works.Published by ehmicky 12 months ago
18.18.0
Published by ehmicky over 1 year ago
Published by ehmicky over 1 year ago
16.17.0
Published by ehmicky almost 2 years ago
Published by ehmicky almost 2 years ago
normalize
option was renamed to loose
. Its value has been inverted: normalize: false
is now loose: true
.loose
option is now false
.
serialize()
is not an error instance, it is now normalized to one, unless loose: true
is usedparse()
is not an error plain object, it is now normalized to one, unless loose: true
is usedPublished by ehmicky almost 2 years ago
Published by ehmicky almost 2 years ago
error
is now passed to afterSerialize()
errorObject
is now passed to afterParse()
Published by ehmicky almost 2 years ago
classes
option was defined, the constructor
is not called anymore unless error.constructorArgs
was setbeforeSerialize()
, afterSerialize()
, beforeParse()
and afterParse()
to customize the serialization and parsing of each errorPublished by ehmicky almost 2 years ago
Published by ehmicky almost 2 years ago
Published by ehmicky about 2 years ago
package.json
Published by ehmicky about 2 years ago
Published by ehmicky about 2 years ago
is-error-instance
Published by ehmicky about 2 years ago
shallow
option with serialize()
Published by ehmicky about 2 years ago
Published by ehmicky about 2 years ago
error.constructorArgs
.Published by ehmicky about 2 years ago
loose
option was renamed to normalize
. Its value has been inverted: loose: true
is now normalize: false
.normalize
option is now false
.
serialize()
is not an error instance, it is not normalized to one anymore, unless normalize: true
is usedparse()
is not an error plain object, it is not normalized to one anymore, unless normalize: true
is usedshallow: true
option can be used to keep them shallow.Published by ehmicky about 2 years ago
types
option to classes
Published by ehmicky about 2 years ago