ultimatebuster 14 Posting Whiz in Training

I'm pretty new to JavaScript.

I'm trying to define my custom errors, but it doesn't seems to be working

function MyError(msg){
    this.message = msg
    this.name = "My Error"
}

body.onload = function(){
    try{ 
        er = new MyError("Test Message")

        throw er();
    } catch(e) {
        alert(e.name + ": " + e.message);
    }
}

Getting TypeError, claiming that it's not a function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.