catch.js
Version:
Catch and handle errors after deployment
1 lines • 719 B
JavaScript
class Catch{browser(a){window&&(window.onerror=(b,c,d,e,f)=>{const g={err:b,src:c,line:d,column:e,errObj:f,time:new Date().toString(),userAgent:window.navigator.userAgent};this.errors.push(g),a(g)})}constructor(a){this.version="v0.0.1",this.listen(a),this.errors=[]}listen(a){"undefined"!=typeof module&&module.exports?this.node(a):this.browser(a)}node(a){process&&process.on("uncaughtException",(b)=>{const c={err:b,time:new Date().toString()};this.errors.push(c),a(c)})}}"function"==typeof define&&define.amd?define(()=>new Catch):"undefined"==typeof exports?"undefined"!=typeof global&&(global.Catch=new Catch):("undefined"!=typeof module&&module.exports&&(exports=module.exports=new Catch),exports.Catch=new Catch);