I've been struggling with error handling in durandal.
I've found it is desirable to to place much much of the logic for rendering views etc in the activate function.
This was working well untill I noticed a few programming errors caused the whole app to fall over very silently. i.e. Nothing written to the console, no trapped error, the app just hangs on the activate function.
Is this expected behaviour. Should I be moving the application logic for my app elsewhere?
The actual code is a little awkward and a lot is wrapped in jquery promises etc.
To prove what I was seeing I wrote the following:
public activate(stationId: string): void {
throw "Error in detail activate";
}
Which wrote nothing to the console and raised no other apparent error, other than hanging the application.
The immediate thing that occurs:
public activate(stationId: string): void {
setTimeout(function() {
throw "Error in detail activate";
}, 0);
}
In this situation the activate function progressed but unfortunately it was not possilbe to track this error either?
I'm concerned that I need to find a way of performing applicaiton logic at activate point, but it would be useful if these errors were not simply swallowed.
Done a little more investigation and digging into Durandal.
The error still disappears. Despite obvious attempts by Durandal to log the error. I have been looking in activator.js activate function:
try {
result = invoke(newItem, 'activate', activationData);
} catch (error) {
system.error(error);
callback(false);
return;
}
Essentially the catch condition is run and system error is called. The result seems to disappear into knockout bindings etc. Is there anyway to make this error more visible. For now I'm stuck with putting a breakpoint on the activator.js activate function.
Am using v2.0.1 of durandal.