Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

User can't specify own error handling logic #2503

Closed
VilleSalonen opened this issue Sep 22, 2011 · 8 comments
Closed

User can't specify own error handling logic #2503

VilleSalonen opened this issue Sep 22, 2011 · 8 comments
Assignees
Milestone

Comments

@VilleSalonen
Copy link

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.

@VilleSalonen
Copy link
Author

Added pull request for this issue: #2504

@jblas
Copy link
Contributor

jblas commented Sep 22, 2011

@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.

@VilleSalonen
Copy link
Author

That sounds even better than my implementation. Any idea how soon this change would land the stable release?

@jblas
Copy link
Contributor

jblas commented Sep 22, 2011

@VilleSalonen

I'll try to land something today.

@ghost ghost assigned jblas Sep 22, 2011
@jblas
Copy link
Contributor

jblas commented Sep 23, 2011

Fix landed on the HEAD:

4f066b7

I'll be checking in the docs for the notifications soon.

@VilleSalonen

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:

$( document ).bind( "pageloadfailed", function( event, data ) {
    // Do what you want.

    data.deferred.reject();
};

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.

@jblas jblas closed this as completed Sep 23, 2011
@hotTea
Copy link

hotTea commented Oct 11, 2011

@jblas

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.

jblas added a commit that referenced this issue Oct 26, 2011
…callbacks. This was a low-hanging-fruit enhancement request for issue #2503 - User can't specify own error handling logic.
@jblas
Copy link
Contributor

jblas commented Oct 26, 2011

@hotTea

I just landed your request on the HEAD. It will appear in 1.0 final.

@hotTea
Copy link

hotTea commented Oct 26, 2011

@jblas Awesome ! Thanks !!

timmywil pushed a commit to timmywil/jquery-mobile that referenced this issue Nov 5, 2011
…callbacks. This was a low-hanging-fruit enhancement request for issue jquery-archive#2503 - User can't specify own error handling logic.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants