我从 Facebook 找到了这段代码,其中有一个我不明白的 try catch。
fb_param 是一个 JS 对象,其中唯一需要的属性是 pixel_id,但该要求由 if 子句检查。
谁能告诉我这段代码如何引发异常?
/*1375267557,179355677,JIT Construction: v893363,en_US*/
/**
* Copyright Facebook Inc.
*
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*/
try {
(function() {
if (typeof fb_param != 'undefined' && fb_param.pixel_id) {
var a = 'https://www.facebook.com/offsite_event.php',
b = a + '?id=' + fb_param.pixel_id;
if (fb_param.value) b += '&value=' + encodeURIComponent(fb_param.value);
if (fb_param.currency) b += '¤cy=' + encodeURIComponent(fb_param.currency);
var c = new Image();
c.src = b;
}
})();
} catch (e) {
new Image().src = "http:\/\/www.facebook.com\/" + 'common/scribe_endpoint.php?c=jssdk_error&m=' + encodeURIComponent('{"error":"LOAD", "extra": {"name":"' + e.name + '","line":"' + (e.lineNumber || e.line) + '","script":"' + (e.fileName || e.sourceURL || e.script) + '","stack":"' + (e.stackTrace || e.stack) + '","message":"' + e.message + '"}}');
}