Skip to content
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

<exception> classes must return their exact name. #17

Closed
samchon opened this issue Nov 10, 2018 · 3 comments
Closed

<exception> classes must return their exact name. #17

samchon opened this issue Nov 10, 2018 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@samchon
Copy link
Owner

samchon commented Nov 10, 2018

All the classes in the <exception> module are derived from the native Error class and they hadn't defined their own name. Thus, whenever call the name getter, error had been returned.

At the next update, they've to return their exact name.

class RuntimeError extends Exception
{
    public get name(): string
    {
        return "runtime_error";
    }
}
@samchon samchon added enhancement New feature or request v2.1 labels Nov 10, 2018
@samchon samchon changed the title <exception> classes have to return its exact name. <exception> classes have to return its exact name. Nov 12, 2018
@samchon samchon removed the v2.1 label Nov 13, 2018
@samchon samchon added the bug Something isn't working label Nov 13, 2018
@samchon samchon closed this as completed Nov 14, 2018
@samchon
Copy link
Owner Author

samchon commented Dec 20, 2018

Additionally, the exception classes do not have their own member methods. They're not being extended. When create an exception instance, it doesn't be the sub-type class, but the origin Error class.

@samchon samchon reopened this Dec 20, 2018
@samchon samchon closed this as completed Dec 21, 2018
@samchon samchon reopened this May 7, 2019
@samchon
Copy link
Owner Author

samchon commented May 7, 2019

Exception.name() returns its class name (Pascal notation).

In JavaScript, it's always possible to knowing class name of a variable. Also, native error class of JS like Error and SyntaxError, their get Error.name() function always return their name as Pascal notation.

Thus, from v2.2 update, the Exception.name() accessor would return its class name itself, with Pascal notation using object.constructor.name;

class Exception extends Error
{
    public get name(): string
    {
        return this.constructor.name;
    }
}

@samchon samchon changed the title <exception> classes have to return its exact name. <exception> classes must return their exact name. May 7, 2019
@samchon
Copy link
Owner Author

samchon commented Jun 15, 2019

Have implemented until v2.1.6 patch and v2.2 update.

@samchon samchon closed this as completed Jun 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant