voyent
Best way to do error handling in ace:dynamicResource ?  XML
Forum Index -> Components
Author Message
MichaelBreu

Joined: 17/Aug/2011 10:08:42
Messages: 13
Offline


Hello,

we are severely struggeling with implementing a smooth error handling wit ace:dynamicResource.

Our case is, that we present the user a list of (quite huge) files loadable from a remote server. The user can download individual files.

When starting the transfer in getInputStream() there may occur various network errors or the file may have been deleted in the meantime Thus we would like to react positively and show an error message to the user.

We have identified various options:
[list]When an error occurs, we would like to return an input stream with an HTML-encoded error message. This would also require to return the contenttype "text/html". However the method getContentType() is already called for each resource, during rendering the list of files.
[/list]
[list]The other option would be, to set Status 302 and add an redirect to an error page in getInputStream(). Is this a valid option, or would this interfere with other output handling?
[/list]

Both solutions fail because the method getContentType(), getHeaders(), etc. are already called for each resource, during rendering the list of files. I have no idea, why this is necessary. At that point in time, we have no chance to check the availability of the input stream.

If we can be sure that these methods are called, only just before the output of the resource, we could store the result of the getInputStream() and take approiate action.

Best regards

Wallenstein


 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team