What I want to do is catch a 302 error which means a user is not logged in, and then redirecting that user to the login page of the website. Here's my backbone.js sync override right now:
parentSynchMethod = Backbone.sync
Backbone.sync = (method, model, success, error) ->
try
parentSynchMethod.apply(Backbone, arguments)
catch error
window.location.replace("http://localhost:8080/login")
The 302 error is definitely happening, I can see it in the network view when I inspect the page using google chrome. However, when I set a breakpoint, it never goes inside the catch, and the error argument is undefined. Is this because 302 is not a real error(it's yellow when I view the status of the response, instead of a usual red for errors, or am I messing up the code somewhere.