views:

320

answers:

1

My Flex3 application must display meaningful application-level error messages from the server.

This article article says that Flash has severe limitations on receiving error info, whether as status codes, response body, or response headers as described. I can use any of these from my servlet. But apparently none are accessible!

But the mx.rpc.events.FaultEvent which my code receives following HTTPService.send on a non-200 HTTP status code does not allow access to any of these!

One workaround is to always pass the 200 "OK" status code, and use XML content in the body, e.g. with an <Error> root tag. But that would completely bypass the Flex fault mechanism, and every one of my event handlers would have to figure out by itself if there had been an error.

I just want to allow some sort of response information to be available on error.

By the way, I always use POST, as Flex passes more information with POST than with GET.

A: 

After futher exploration, it seems that there is no non-hacky way to do this.

HTTPService simply does not pass through any information about errors.

So, you have to write a workaround layer to handle errors as described above: Always pass the 200 "OK" status code, and use XML content in the body, e.g. with an <Error> root tag and the status code in the XML. Then, create a layer which calls-back with a Fault in case of non-200 status in the XML.

Joshua Fox