-
Notifications
You must be signed in to change notification settings - Fork 2.4k
User can't specify own error handling logic #2503
Comments
Added pull request for this issue: #2504 |
@VillSalonen I was actually going to add pagebeforeload, pageload, and pageloadfailed event triggers so folks could get notifications. I can make the pageloadfailed an event that you can call preventDefault() on to cancel the default behavior and indicate that you have handled it. Doing it in this manner allows folks to register multiple handlers for debugging purposes, and still be able to have their own error/page handlers in place. |
That sounds even better than my implementation. Any idea how soon this change would land the stable release? |
I'll try to land something today. |
Fix landed on the HEAD: I'll be checking in the docs for the notifications soon. Note that when you preventDefault() on the pageloadfailed event, you need to make sure you call resolve/reject on the deferred object so that the framework can continue on it's normal flow. Example:
The reason I don't handle that for you is because the developer may want to load something else when they get a failure, in which case they would call data.deferred.resolve(data.absUrl, data.options) to signal success instead of a fail. |
Your solution is awesome. I was wondering if there was any issue passing the xhr object as well with the data when the "pageloadfailed" event is triggered. for eg. triggerData.xhr = xhr; This would allow developers to work with the response returned from the server. Or is that data already available to devs through some other mechanism ? Thanks. Since this is an inquiry, I didn't open a new bug and thought it would be appropriate to ask here. |
…callbacks. This was a low-hanging-fruit enhancement request for issue #2503 - User can't specify own error handling logic.
I just landed your request on the HEAD. It will appear in 1.0 final. |
@jblas Awesome ! Thanks !! |
…callbacks. This was a low-hanging-fruit enhancement request for issue jquery-archive#2503 - User can't specify own error handling logic.
If there's an error when loading a page, just the page loading error message is shown. For example I'm working on a site where user has to be authenticated to access pages and if the authentication session dies between page loads, user just gets the basic error loading message.
I'm proposing adding a new setting with which developer can specify her own error handling function which can for example show different error message based on the error type or redirect the user to login page.
The text was updated successfully, but these errors were encountered: