1.1.0 • Published 5 months ago
err-utils v1.1.0
err-utils
这是一个用于在Node.js中处理错误的实用函数集合。 ‘ err-utils ’模块为Node.js中的错误处理提供了一组实用函数。它包括用于创建自定义错误对象、检查错误是否是特定错误类型的实例以及通过将错误记录到数据库并发送邮箱给运维人员。 下面是每个函数的简要描述: 1. ‘ reportAnError(err, authentication) ’:这个函数用指定的消息和状态码创建一个自定义错误对象。它返回错误对象。 下面是如何使用这些函数的示例:
### vue main.js/ts
const {reportAnError} = require('err-utils');
//全局监听错误
Vue.config.errorHandler = function (err, vm, info) {
reportAnError(err,'MTAyMDEyMA==');
}
window.onerror = function(message, source, lineno, colno){
console.log('window.onerror', message, source, lineno, colno);
reportAnError({message, source, lineno, colno},'MTAyMDEyMA==');
}
2.入参解释
err{message, source, lineno, colno},authentication
err:监听获得的数据
authentication:为beas64格式