- Added JS debug lib
This commit is contained in:
1 parent
3590993925
commit
ef43c7831f
4 files changed
+69
No files matched your search
@@ -0,0 +1,46 @@
|
||||
|
||||
class ErrorHandler
|
||||
{
|
||||
constructor(options) {
|
||||
if ( options ) {
|
||||
if ( "url" in options ) {
|
||||
this.url = options['url'];
|
||||
}
|
||||
}
|
||||
|
||||
this.catchError();
|
||||
}
|
||||
|
||||
catchError() {
|
||||
window.onerror = function(message, url, line, column, error) {
|
||||
fetch(this.url ? this.url : window.location.href, {
|
||||
method: "post",
|
||||
headers: {
|
||||
'Accept': "application/json",
|
||||
'Content-Type': "application/json",
|
||||
'User-Agent': "NegundoClient/1.0"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
message: message,
|
||||
url: url,
|
||||
line: line,
|
||||
column: column,
|
||||
stack: error.stack,
|
||||
location: window.location.toString()
|
||||
})
|
||||
}).then( response => response ).then(data => {
|
||||
console.info("Error reported", data);
|
||||
});
|
||||
|
||||
return false;
|
||||
}.bind(this);
|
||||
}
|
||||
|
||||
get url() {
|
||||
return this._url;
|
||||
}
|
||||
|
||||
set url(set) {
|
||||
return this._url = set;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user