Menu

Response code handling

2014-11-26
2014-11-27
  • Mikhail Gostev

    Mikhail Gostev - 2014-11-26

    Hi
    I've meet the problem with response code handling. I expect to get it from UploadErrorEvent.getErrorCodeAsInt() but it doesn't work. This method returns some internal error code but I need HTTP error code. I tried to redirect some non 200 http responses to upload success handler, but method Uploader.setHttpSuccess() produces an exception and seems doesn't work at all

    java.lang.ClassCastException: [J cannot be cast to [Ljava.lang.Object;
    at org.moxieapps.gwt.uploader.client.Configurable.convertToJSONValue(Configurable.java:137)
    at org.moxieapps.gwt.uploader.client.Configurable.setOption(Configurable.java:116)
    at org.moxieapps.gwt.uploader.client.Configurable.setOption(Configurable.java:78)
    at org.moxieapps.gwt.uploader.client.Uploader.setOption(Uploader.java:1231)
    at org.moxieapps.gwt.uploader.client.Uploader.setHttpSuccess(Uploader.java:423)

     

    Last edit: Mikhail Gostev 2014-11-26
  • Shawn Quinn

    Shawn Quinn - 2014-11-26

    I'll get a bug in to have someone take a look into that ClassCastException.

    Regarding the error code: it depends a bit on how your server is responding with the error code, but you'll likely find what you're looking for in UploadErrorEvent.getMessage().

     
  • Mikhail Gostev

    Mikhail Gostev - 2014-11-27

    You are right I do things like this

    if( uploadErrorEvent.getMessage().endsWith(" 403") )

    But it is very unreliable trick as it is based on the undocumented error message format and if you change this format it will ruin my application. Not good. And I see no logic when UploadSuccessEvent provides access to response code but UploadErrorEvent not, although usually there is one reason for success (200) but many different for errors (403,404,...).

     

Log in to post a comment.