-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it alive? #7
Comments
Yes it's still alive. I just haven't had to add any features (and I did take a break from web dev related things for a while admittedly). One of the motivations behind this library is that every other Error sub-classing library I could find was feature-ridden, when all I wanted was a bare minimum subclass. That being said, people do want extra features for good reasons. If possible I would like this library to be set up such that if someone has a feature they really want, they can use this and build their functionality on top of it and make that a library, without forcing everyone else to have a ton of functionality they don't need. How would each of these features work in terms of API? I feel like the pretty printing could be done easily here by allowing the user to pass a custom print function. |
Thank you for reply. I definitely agree that the feature-rich error processing library will make it quite heavy in runtime. For example:
Hope, you'll find these reasons important to extend the library and accept PR's, addressing these issues. |
Thanks for the suggestions. I've thought about this some, and I agree that these would be great to have, and that they could be done without causing bloat. I still feel like most of these can be implemented by adding some sort of hooks into the code. What this library does currently is:
The features you have suggested could be implemented by allowing properties (something like Keep in mind though that the way that the stack is formatted varies across environments, as I just pushed a couple of commits that moves some functionality to functions so that they can be overwritten, though the constructor will still need to changed to allow the constructor arguments to be consumed. What are your thoughts on this? |
Thank you, this definitely makes sense. Here's the usage sample var E1 = new CustomError('E1');
var E2 = new CustomError('E2', E1);
var E3 = new CustomError('E3', E2, function (message, code) {
this.code = code;
this.toString = function () {
return `[${this.name}:${this.code}] ${this.message}`;
}
this.inspect = function () {
return `[${this.name}:${this.code}] ${this.message}`;
}
});
var E4 = new CustomError('E4', E3, function (message, code) {
this.inspect = function () {
return `[${this.name}:${this.code}] ${this.message}; Caused by ${this.nested}`;
}
});
var e1 = new E1('test1');
var e2 = new E2('test2');
var e3 = new E3('test3', 3);
var e4 = new E4(e3, 'test4', 4);
var e5 = new E4(new Error('test'), 'test5', 5);
console.log(e1, JSON.stringify(e1));
console.log(e2, JSON.stringify(e2));
console.log(e3, JSON.stringify(e3));
console.log(e4, JSON.stringify(e4));
console.log(e5, JSON.stringify(e5)); |
So, what do you think? |
Hi,
I'd like to add some features like nested errors and pretty error printing, but not sure whether the lib is alive.
Thanks.
The text was updated successfully, but these errors were encountered: