@cdellacqua/serializable-error

Custom error class that supports JSON serialization and concatenation


Keywords
error, serializable, json
License
MIT
Install
npm install @cdellacqua/serializable-error@1.1.4

Documentation

serializable-error

Custom error class that supports JSON serialization and concatenation

NPM Package

npm install @cdellacqua/serializable-error

Full documentation:

Highlights

Keep track of what caused the error

try {
	someFunctionThatThrows();
} catch (err) {
	// some error handling logic
	// ...
	throw new SerializableError('something more specific about the current exception', err);
}

Exception logging

try {
	someFunctionThatThrows();
} catch (err) {
	logger.log(SerializableError.from(err));
	// or, if it only accepts strings
	logger.log(JSON.stringify(SerializableError.from(err)));
	throw err;
}