Skip to content

Instantly share code, notes, and snippets.

@nitso
nitso / gist:c6c8fa9ea8519139ef6b
Created May 8, 2015 10:43
Angular $http init: json error interceptor + POST processor
(function($) {
var jsonErrorInterceptor = function($q) {
return function(promise) {
// error handler
var triggerError = function(message) {
if (message instanceof Array) {
message = message[0];
}
console.log(message);
};
var getStackTrace = function() {
if (typeof Error.captureStackTrace == 'undefined') {
return [];
}
var obj = {};
Error.captureStackTrace(obj, getStackTrace);
var trace = obj.stack.split("\n");
trace.splice(0, 2);