Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
format-error
Advanced tools
Formats an error object such that:
npm install --save format-error
var format = require('format-error').format;
var error = new Error('something broke');
error.inner = new Error('some inner thing broke');
error.code = '500c';
error.severity = 'high';
var message = format(error);
console.error(message);
/*
Error: something broke
at Object.<anonymous> (/home/sean/demo/testium/err.js:28:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
inner:
Error: some inner thing broke
at Object.<anonymous> (/home/sean/demo/testium/err.js:29:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
code: 500c
severity: high
*/
Formats an error for output.
error
is an Error object.
prettyjsonOptions
(optional) is passed directly to
prettyjson.
Permanently patches the error object
such that serialization (toJSON
calls)
behave according to the goals
of this module.
This is not required
unless you want JSON.stringify(error)
to act somewhat like format(error)
in cases where you can't
control how the output is formatted directly.
This module only temporarily patches Error in order to produce the formatted output.
This can be undone by calling unpatchError()
.
This reverts changes made to
Error.prototype.toJSON
by patchError()
.
This should only be called if
you explictly called patchError
.
FAQs
formats an error for display
The npm package format-error receives a total of 1,766 weekly downloads. As such, format-error popularity was classified as popular.
We found that format-error demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.