Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

DataLoader onFail and server response

Recommended Posts

Maybe I am just missing it, but I can't seem to find where the servers response is stored when onFail is fired for a DataLoader. I have been digging through the event in the debugger and I don't see it, but when I look at the request/response in Charles proxy I see a json response even though its coming back as a 404. Am I just missing it?

Link to comment
Share on other sites

Any error text is stored in the LoaderEvent's "text" property, and any associated raw event that is received is stored in the "data" property of the LoaderEvent. Keep in mind that not all errors/failures in Flash provide those, though. LoaderMax does its best to take whatever info it gets and passes it along in the LoaderEvent as the text and data.

Link to comment
Share on other sites

Thats what I thought. I am seeing one of these guys in the text: Error #2032: Stream Error

And the data property has the IOErrorEvent in it, which doesn't have the response either.


In this particular case there is also a valid response sent from the server that indicates what the error was via json, but comes back as a 404 as well.

Link to comment
Share on other sites

Hmmm...I'm not quite sure what else to advise here because I don't think Flash provides access to that data. Sorry :(

Link to comment
Share on other sites

  • 1 year later...

Hmm, this seems like a deal breaker. It's pretty vital that we can get data about a server error, beyond a generic "Stream Error" and an HTTP status. For example, creating a new player in a game, how would our flash tell the difference between two different server errors "username in use" and "username must be alphanumeric"?


The server response would commonly be HTTP status 400, with JSON content something like:


  "type": "usernameInUse",

  "message": "Sorry, username is already taken."



I can't seem to find any way to get that kind of data into my LoaderMax onError handler. 


Perhaps the workaround is to avoid HTTP error statuses altogether – the server sends a success status (200) and JSON error object, and in the LoaderMax onComplete handler we check for that error object in event.target.content. Bit hacky/non-standard/non-resty, but it works.


PS Love greensock, many thanks!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.