GWT: How to return (and handle) an error from multipart form (file) upload

Viewed 4591

I have and Google Web Toolkit (Multipart) Form which post a file to my servlet. When error condition is happening in servlet I return an error. When everything is OK I return an JSON string.

    ...
    response.setContentType("text/html");
    response.setCharacterEncoding("UTF8");
    response.getWriter().write(out.toString());

} catch (FileUploadException e) {
    response.sendError(500, e.getMessage());
} catch (Exception e) {
    response.sendError(500, e.getMessage());
}

The problem is that I cant find a way to handle this in client side. This is the event that is fired when post goes OK and when error code is returned. But I can't find how to find is it OK or NOT? And how can I get an error message from Exception in client code?

@UiHandler("form")
void submitComplete(SubmitCompleteEvent event)
{
    ...

Debug

1 Answers
Related