-
Notifications
You must be signed in to change notification settings - Fork 593
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
Restructure JavaScript exceptions #2562
Conversation
export class UserException extends Exception { | ||
constructor() { | ||
super(); | ||
Exception.captureStackTrace(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably remove this, not sure why we were capturing stack traces for user exceptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shoud remove it. Can we then remove the constructor entirely?
The only relevant change is the updated UserException, constructor. The rest is to move classes around and update the import paths. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the actual refactoring of the local exceptions is for a follow-up PR?
export class UserException extends Exception { | ||
constructor() { | ||
super(); | ||
Exception.captureStackTrace(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shoud remove it. Can we then remove the constructor entirely?
* This exception is raised when a failure occurs during initialization. | ||
**/ | ||
export class InitializationException extends LocalException { | ||
constructor(reason = "", _cause = "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the reason is defaulted to "". We should also provide a reason when we construct an InitializationException.
Is it possible to make a class as final/sealed in JS? If yes, then, we should use it in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will cleanup in a follow-up PR
* user exception factory more than once for the same ID. | ||
**/ | ||
export class AlreadyRegisteredException extends LocalException { | ||
constructor(kindOfObject = "", id = "", _cause = "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, kindOfObject and id must always be provided by the caller.
@@ -38,7 +38,7 @@ const toString = function (key, object, objectTable, ident) { | |||
// | |||
// Ice.Exception | |||
// | |||
class Exception extends Error { | |||
export class Exception extends Error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use/fill Error.cause and Error.message, and definitely not define our own ice_cause property.
Also update the UserException constructor to not take a cause argument, as per #2527