Skip to content

Instantly share code, notes, and snippets.

@katowulf
Last active May 30, 2016 21:27
Show Gist options
  • Save katowulf/9073ad8ea56281e0de6d to your computer and use it in GitHub Desktop.
Save katowulf/9073ad8ea56281e0de6d to your computer and use it in GitHub Desktop.
Overriding error handling in AngularFire by extending and decorating $$error
// this will remove all error logging globally
angular.config(function($provide) {
$provide.decorator("$firebaseObject", function($delegate) {
$delegate.prototype.$$error = function(err) {
this.$destroy(err);
};
return $delegate;
});
$provide.decorator("$firebaseArray", function($delegate) {
$delegate.prototype.$$error = function(err) {
this.$destroy(err);
};
return $delegate;
});
});
// this will modify error handling for a single instance
angular.service('ArrayWithSuppressedErrors', function($firebaseArray) {
var ArrayService = $firebaseArray.$extend({
$$error: function(err) {
this.$destroy(err);
}
});
return function(ref) {
return new ArrayService(ref);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment