정의 된 네임 스페이스 내에없는 오류를 무시 하도록 raven-js 를 구성 할 수 있습니까?
var Foo = Foo || {};
Foo.raiseWithinNamespace = function(){
//bar is not defined, raises
return bar;
}
function raiseOutOfNameSpace(){
//bar is not defined, raises
return bar;
}
그래서 Foo.raiseWithinNamespace
포착되고 raiseOutOfNameSpace
무시됩니다.
네임 스페이스의 각 함수를 다음에서 만든 래퍼로 간단히 바꿀 수 있습니다 Raven.wrap()
.
// Do not catch global errors
Raven.config(..., {collectWindowErrors: false}).install()
// Helper to catch exceptions for namespace
function catchInNamespace(ns)
{
for (var key in ns)
{
if (ns.hasOwnProperty(key) && typeof ns[key] == "function")
ns[key] = Raven.wrap(ns[key]);
}
}
// Declaration of namespace Foo
var Foo = Foo || {};
Foo.func1 = ...;
Foo.func2 = ...;
catchInNamespace(Foo);
// Using namespace
Foo.func1(); // Any exceptions here are caught by Raven.js
참고 collectWindowErrors: false
이 Raven.js는 암시 적으로 모든 예외를 잡을 것없이, 구성 옵션이 다른 네임 스페이스 및 전역 함수에서 오류를 무시하는 데 필요합니다. 이 옵션은 Raven.js 1.1.0에서 도입 되었지만 어떤 이유로 아직 문서화되지 않았습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다