Good afternoon all,
I am implementing RayGun, an error-tracking service; it is working in all places, EXCEPT in the initialize/update functions (and I assume in all other “script methods”).
When I pause the code with a debugger, I get the following behavior:
- In normal functions, the thread ends at the error, and RayGun somehow finds and reports it.
- However, in initialize/update functions, when an error gets thrown, the thread does not end, but rather enters the
catch
block of a function called_scriptMethod(script, method, arg)
, and the error doesn’t get reported to RayGun.
I assume that this function is invoked on all “script methods”, and it is somehow preventing RayGun from finding the error.
This is what that function looks like:
_proto._scriptMethod = function _scriptMethod(script, method, arg) {
try {
script[method](arg);
} catch (ex) {
script.enabled = false;
if (!script._callbacks || !script._callbacks.error) {
console.warn("unhandled exception while calling \"" + method + "\" for \"" + script.__scriptType.__name + "\" script: ", ex);
console.error(ex);
}
script.fire('error', ex, method);
this.fire('error', script, ex, method);
}
};
Does anyone know what I can do to solve this? (by “solve” I mean, get RayGun to report errors inside of script methods).
One solution is to wrap every script method in a try/catch block, and send the error manually to RayGun in the catch block. However, if there is a way to avoid this, that would be incredible, because the automatic reporting is much cooler and more maintainable.
Thank you very much for any help anyone might be able to provide
Best,
Michael King.
(P.S. The way I have implemented RayGun is by storing the RayGun scripts in an S3 bucket, and then adding links to those 2 scripts in the “external scripts” section of the Editor settings. From there, it is magically working, except in the script methods).