Skip to content

Commit

Permalink
Change error handling
Browse files Browse the repository at this point in the history
Local error handlers take priority — if none, then global. If no global
unload or error. If the calling app wants to pass local error handling
to global they can do that outside of rest.
  • Loading branch information
jasonkneen committed Apr 21, 2017
1 parent 873e655 commit 9eb0221
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions reste.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,10 @@ var main = function() {
warn("RESTE:: Future versions of RESTe will return errors as objects. Use config.errorsAsObjects = true to support this now and update your apps!");
}

// if we have an onError method, use it
if (config.onError) {
// if we have a global onError, we'll pass it on too do we can still use it locally if we want to
if (onError) {
onError(error, retry, config.onError);
} else {
config.onError(error, retry);
}
} else if (onError) {
if (onError) {
onError(error, retry);
} else if (config.onError) {
config.onError(error, retry);
} else if (onLoad) {
// otherwise revert to the onLoad callback
onLoad(error, retry);
Expand Down

0 comments on commit 9eb0221

Please sign in to comment.