Skip to content

Instantly share code, notes, and snippets.

@abrkn
Created November 21, 2012 12:44
Show Gist options
  • Save abrkn/4124683 to your computer and use it in GitHub Desktop.
Save abrkn/4124683 to your computer and use it in GitHub Desktop.
Backbone.wrapError = _.wrap(Backbone.wrapError, this.wrapError)
},
wrapError: function(inner, onError, originalModel, options) {
var onErrorWrap = function(model, xhr, options) {
xhr.body = JSON.parse(xhr.responseText) || xhr.responseText
if (!onError || !onError(model, xhr, options)) {
if (xhr.status == 401) {
app.session.forget()
return app.authorize()
} else {
console.error('unhandled sync error', model, xhr, options)
}
}
}
return inner(onErrorWrap, originalModel, options)
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment