所以这感觉就像一个愚蠢的问题。希望我只是忽略了一些显而易见的事情,但我正在倾听视频元素的错误。错误字符串实际显示在控制台中,并且错误事件正常触发,但是当我浏览错误对象时,我似乎无法在任何地方找到该字符串。我的目标是简单地记录此错误以用于记录目的。另一种选择是获取错误代码 - 任何可以记录的内容都可以为我们的调试器提供关于实际问题的线索。知道如何从视频标签错误对象中获取错误字符串或代码吗?
代码:
$(this.video)
.on( 'error', this.proxy(this.onVideoError));
onVideoError : function(e) {
console.log(e, " the e");
console.log(e.toString());//prints [object Object]
console.log(e.code, " the code");// prints undefined
},
答案 0 :(得分:0)
在我的错误处理程序中,我使用的是err.name
和err.message
成员。
由于错误实际上没有PHP或其他语言的代码,您可能需要解析消息和名称以创建自己的代码。
var errorHandler = function(err) {
// prints the name of the error
console.log(err.name);
// prints the description that is also shown in the error console
console.log(err.message);
// this works only in some browsers
// line and stack are not supported by all vendors
console.log(err.line, err.stack);
}