More info for errors in save process

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

More info for errors in save process

bwallis42
I have a save-final process that ends with the following code

        then
        success-message("save-success")
        then
        navigate(uri = "javascript:closeEdit('...','close')")
        recover
        error-message(message="Error saving form 
                {xxf:instance('fr-parameters-instance')/app}/{xxf:instance('fr-parameters-instance')/form}/{xxf:instance('fr-parameters-instance')/document}.
                Save a draft and then try saving again, if it continues to fail please contact your system administrator")

What I would really like to do is be able to provide some information about what was the error that occurred. Often for us it is some sort of persistence layer failure such as an expired session.

Can I get any other information to include in the error dialog that is shown to the user? Even if all I can get is the HTTP error code and message returned from the persistence layer, that would be quite useful.

thanks.
Reply | Threaded
Open this post in threaded view
|

Re: More info for errors in save process

bwallis42
It occurs to me, in reference to another post, that this might help in handling optimistic locking scenarios.

If the persistence layer can detect a collision then it should return an http status to the PUT operation for the form of "409, Edit Conflict".  

If I could detect and handle this http error code in the save process I could present the user with a more sensible error message..
Reply | Threaded
Open this post in threaded view
|

Re: More info for errors in save process

Alessandro  Vernet
Administrator
Hi Brian,

Right now, you can't have access to that information. When save() fails a SubmitException will be thrown, which contains a XFormsSubmitErrorEvent, which might have the information you're looking for. The `recover` combinator has access to the information, but doesn't make it available to the expression it runs. If we want to do this, we'll have to think of a mechanism to make an exception available in a process.

This could be part of a solution to handle collisions, but as mentioned in the  issue linked in the other thread, this alone wouldn't be enough.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: More info for errors in save process

bwallis42
I've been working through my options here and for other errors (particularly session timeouts) I have added a new error-dialog.xml to my configuration and have an event  subscription function (ORBEON.xforms.Events.errorEvent.subscribe) that populates my error-dialog with additional error details. This works pretty well.

Can I do something similar for the dialog used for the recover error-message command? Is there an appropriate event I can subscribe to for save errors?

My alternative to that would be to use a navigate() command to run a javascript function that could popup an alert or similar containing more appropriate error details but that would look out of place, reusing the error-dialog or having my own dialog for the error-message command would be cleaner I think.
Reply | Threaded
Open this post in threaded view
|

Re: More info for errors in save process

Alessandro  Vernet
Administrator
Hi Brian,

The errorEvent is fired when there is an error with an Ajax response. Are you saying that you'd like to run JavaScript code on recover? I was going to suggest to use navigate(), using a URL with the javascript: syntax for this:

http://doc.orbeon.com/form-runner/advanced/buttons-and-processes/actions-form-runner.html#navigate

But you've already thought about it! Do you see a problem with that? You have full control over what happens, since it runs your JavaScript, so it should work for your use case, shouldn't it?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: More info for errors in save process

bwallis42
Yes, I can make the navigate work and that isn't a bad solution, but I need to present the details of the error to the user and I'm not sure how to do that. Popping up a standard javascript alert would work quite well but since the other alert is a floating div, the standard javascript alert dialog box would look out of place.

So, yes functionality is very possible but I would like to re-use the existing error_message dialog box and populate it from javascript with a more informative message.

As mentioned earlier this has worked out quite well for the ajax error dialog, I have my own error-dialog.xml which has a div with a particular ID in it that I populate with appropriate error information from my javascript code in the event handler.
Reply | Threaded
Open this post in threaded view
|

Re: More info for errors in save process

Alessandro  Vernet
Administrator
Hi Brian,

So it comes down to how to know what the error is from a process. And right now, this isn't possible, as mentioned in my message of 2016-03-01.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet