Simple client side error logging
metric.io
metric.io
This code, for example, reports each otherwise unhandled exception to user prettily using Messenger.js:
window.angular.module('yourApp', []).
// <…>
factory('$exceptionHandler', [
'$log',
function ($log) {
return function (exception, cause) {
// Log to console
$log.error.apply($log, arguments);
// Show to user
var msg = sprintf("Error: %s", exception.message);
if (cause) { msg = sprintf("%s. %s", msg, cause); }
window.Messenger().post({
type: 'error',
hideAfter: 0,
showCloseButton: true,
message: msg
});
};
}
]);
To replicate functionality from the article, you could make a request using $http service in there.(I assume it's possible to override not $exceptionHandler, but $log service directly. This would allow for more extensive server-side log collection, not just error reporting. Never tried that myself, though.)
I have refactored my js code to have try - catch block in all my critical paths in Babckbone modules; this approach works on all google closure compiler generate javascript code. I really wonder why most people don't do this more often.
"free trail", "build lasting realtionships", "Create pomotions", "siing how your customers are interacting"
You've got a beautiful site but these sorts of errors give the wrong first impression.
and the heading and menus on your page overlap on Chrome under Windows when the browser is sufficiently narrow
'All beta-barrels can be classified in terms of two integer parameters: the number of strands in the beta-sheet, n, and the "shear number", S, a measure of the stagger of the strands in the beta-sheet.'
This is one such time, despite knowing about onerror I honestly don't think I would have ever thought of doing this myself...it's simply brilliant.
Thank you for the post.