I have a situation in my code where i need to trace the errors in my production.
I used ember.js as my framework.
To trace the errors occuring in production i used Ember.Onerror which provides me only any functionality error trace.
Ember.onerror = function(error) {
Em.$.ajax('/error-notification', 'POST', {
stack: error.stack,
otherInformation: 'exception message'
});
}
But i would like to trace the assertion failed errors for example
The URL * didnot match any of the routers in your application*
There is really few documentation on Ember about catching errors and assertions errors. In my case, I needed to visualize these exceptions beyond the console in my debug mode, before going into production. So, I went to the Ember project in GitHub and found the specification and implementation for the Ember.onerror(error) {...} and Ember.assert(desc, test) {...} functions and then I just wrote my own version of these functions inside the initialize function of a new adapter (app/initializers folder) that I decided to name errorHandler.
Ember.assert = function(desc, test) {
if (!test) {
console.log('This is a test to log Assertions!');
/* your assertion treatment code goes here*/
throw new Ember.Error("Assertion Failed: " + desc);
}
}
...and by throwing that new Ember.Error(...) you are actually calling:
Ember.onerror = function(error) {
console.log("An error has occurred in ember: " + error.message);
/* your error treatment code goes here*/
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With