Timon-D3v / timon.js

This package contains some functions and variables that I (Timon Fiedler) need from time to time.
MIT License
0 stars 0 forks source link

Better Error handling #7

Closed Timon-D3v closed 1 month ago

Timon-D3v commented 4 months ago

Please add a better error system. My idea would be to create a class that extends the normal error. Similar like this:

class testError extends Error {
    constructor(id) {
        super(id);
        this.message = `The element with id ${id} does not exist!`;
    }
}

throw new TestError( "myId");

This would show up similar like this: image

While it now is like this: image image

Timon-D3v commented 1 month ago

I did it with a error function that is called when something does not work. Usage:

errorFunction("on");

// While the error function looks like this:
const errorFunction = id => console.log(`There was a error while setting .${id} and the replaced function is called ._${id}`)