前端错误信息收集(errorEruda)解析
2017-08-24 22:38
183 查看
github:errorEruda移动调试,bug收集工具
img[src],script[src],link[href]请求链接错误监控:
document.addEventListener("error", function (e) {
let error = '';
if (e.target.localName == 'link') {
error = e.target.href;
}
else {
error = e.target.src;
}
}, true);
通过js委托事件实现,监控所有的外链error错误信息;(注:该方法应该第一个执行)
监控js错误:
window.onerror = function (msg, url, line, col, error) {
console.log(error.stack)
};
一般js错误会通过window.onerror进行触发,error.stack包含了具体错误信息
监控XHR接口请求:
var open = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function (method, url) {
this.addEventListener('readystatechange', function () {
if (this.readyState == 4 && this.status != 200) {
//url请求链接完整,method请求方式,status:http状态码
}
})
open.apply(this, arguments);
}
这样一个简单的错误收集就完成了
在移动端真机测试:
demo:http://jqvue.com/demo/errorEruda/index.html
点击按钮6次即可调起模拟控制台
img[src],script[src],link[href]请求链接错误监控:
document.addEventListener("error", function (e) {
let error = '';
if (e.target.localName == 'link') {
error = e.target.href;
}
else {
error = e.target.src;
}
}, true);
通过js委托事件实现,监控所有的外链error错误信息;(注:该方法应该第一个执行)
监控js错误:
window.onerror = function (msg, url, line, col, error) {
console.log(error.stack)
};
一般js错误会通过window.onerror进行触发,error.stack包含了具体错误信息
监控XHR接口请求:
var open = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function (method, url) {
this.addEventListener('readystatechange', function () {
if (this.readyState == 4 && this.status != 200) {
//url请求链接完整,method请求方式,status:http状态码
}
})
open.apply(this, arguments);
}
这样一个简单的错误收集就完成了
在移动端真机测试:
demo:http://jqvue.com/demo/errorEruda/index.html
点击按钮6次即可调起模拟控制台
相关文章推荐
- GetLastError错误码信息收集
- 错误 4 error LNK2019: 无法解析的外部符号 "public: __thiscall CRobotProvider::~CRobotProvider(void)" (??1CRobotP
- ajax使用jsonp跨域调用webservice error错误信息"readyState":4,"status":200,"statusText":"success"
- PHP文件上传、客户端和服务器端加限制、抓取错误信息、完整步骤解析
- 经典错误::error LNK2019:无法解析的外部符号 ,该符号在函数**中被引用
- .NET Interop: 从IErrorInfo错误对象获得托管代码的异常信息
- java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)
- curl 函数执行了之后返回false解决,打印错误信息返回PHP的Curl出现:curl call error(77): Problem with the SSL CA cert (path? ac
- 转:java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)
- Android 错误信息: java.lang.StackOverflowError: stack size 8MB
- Django 错误信息:AttributeError: 'str' object has no attribute '_meta'
- java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)
- java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)
- vs2013下配置opencv2.4.9&openNI2提示错误:error LNK2019: 无法解析的外部符号
- 关于appStore验证错误信息解析
- sharepoint开发中,页面报“未知错误”或“Unknown Error”后,如何查看详细错误信息
- okhttp上传返回的加密信息解析错误
- .NET Interop: 从IErrorInfo错误对象获得托管代码的异常信息
- 边学边做ROR( 错误信息error_messages_for was removed from Rails and is now available as a plugin)
- 百篇大计敬本年之最强辅助《三》 —— Makefile 高亮显示Error、Warning等错误以及警告信息