
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
The ErrorZone framework helps to use error stack data more efficiently.
npm install ezone
bower install e3
This framework supports the same environments as the error polyfill lib.
I used Karma with Browserify to test the framework in browsers and I used Yadda to run the BDD tests.
The error polyfill and the o3 libs are required.
In this documentation I used the framework as follows:
var e3 = require("ezone"),
UserError = e3.UserError,
CompositeError = e3.CompositeError,
Stack = e3.Stack,
CompositeStack = e3.CompositeStack;
You can create custom Error sub-classes by extending the UserError class.
var MyError = UserError.extend({
prototype: {
name: "MyError"
}
});
try {
throw new MyError("problem");
}
catch (theProblem) {
if (!(theProblem instanceof MyError))
throw theProblem;
console.log(theProblem);
// MyError: problem
console.log(Error.getStackTrace(theProblem).toString());
// MyError: problem
// at (example.js:2:16)
// at ...
// ...
}
Overriding and reusing the constructor and the clone method is not recommended by descendant classes, use build and init instead!
You can create composite errors with the CompositeError class if you want to report complex problems, which can only described by a hierarchy of error objects.
var MyCompositeError = CompositeError.extend({
prototype: {
name: "MyCompositeError"
}
});
try {
try {
throw new MyError("problem");
}
catch (theProblem) {
throw new MyCompositeError({
message: "complex problem",
theSource: theProblem
})
}
}
catch (theComplexProblem) {
console.log(Error.getStackTrace(theComplexProblem).toString());
// MyCompositeError: complex problem
// at (example.js:5:32)
// at ...
// ...
// caused by <theSource> MyError: problem
// at (example.js:2:16)
// at ...
// ...
}
The CompositeError can be a great help for example by nested validation errors or by reporting about multiple parallel async failures.
If you have your Stack instance, you can access the frames array by reading the stack.frames property.
var stack = Error.getStackTrace(error);
var frames = stack.frames;
for (var index in frames) {
var frame = frames[index];
console.log(frame.toString()); // e.g. "fn (example.js:1:1)"
console.log(frame.getFunction()); // e.g. function fn(){}
}
People tend to use the error.stack as it were a string. This is usually not a wrong assumption, so I added this feature to the lib.
var error = new UserError("cause");
var lines = error.stack.split("\n");
for (var i in lines)
console.log(line[i]);
This should work despite the fact that the error.stack contains a Stack instance by UserError.
MIT - 2015 Jánszky László Lajos
FAQs
ErrorZone - Javascript Error Framework
The npm package ezone receives a total of 15 weekly downloads. As such, ezone popularity was classified as not popular.
We found that ezone 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.