How to update JavaScript Error class -


i want when 1 of evalerror, rangeerror, referenceerror, syntaxerror, typeerror, urierror thrown through code want these error should thrown after ajex request can know analyse client error logs.

when went deep, found sevral interface created these error extending error class e.g.

interface typeerror extends error { } interface typeerrorconstructor {     new (message?: string): typeerror;     (message?: string): typeerror;     prototype: typeerror; }  declare var typeerror: typeerrorconstructor;      interface error {     name: string;     message: string; }  interface errorconstructor {     new (message?: string): error;     (message?: string): error;     prototype: error; }  declare var error: errorconstructor; 

so there way redefine/update these interface defination before throwing these error should make ajex request server.

note: i dont want use windows.onerror since other library(rollbar) has own onerror implimentation.

is possible redefine these interface. e.g. can redefine console.log follows:

console.log=function(){    return arguments; } 

i faced same issue , solved redefining error class

as follows:

var error = {        name: this.name,        message: this.message,        tostring: function () {             window.rollbar.error("something went wrong", this.message );                   ......             return this.message;        }    }; 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -