How to handle custom Java exception in Flex app.
Posted
by mico
on Stack Overflow
See other posts from Stack Overflow
or by mico
Published on 2010-03-18T12:44:45Z
Indexed on
2010/03/22
13:41 UTC
Read the original article
Hit count: 456
Hello, we are using BlazeDS as a proxy between Flex and Java. The approach is the same as in (http://www.flexpasta.com/index.php/2008/05/16/exception-handling-with-blazeds-and-flex/)
Java exception declaration:
public class FlexException extends RuntimeException {
private String name = 'John';
public FlexException(String message) {
super(message);
}
public String getName() {
return name;
}
}
Then, we are throwing it:
public void testMethod(String str) throws Exception {
throw new FlexException("Custom exception");
}
Flex part:
private function faultHandler(event:FaultEvent):void
{
var errorMessage:ErrorMessage = event.message as ErrorMessage;
trace("error++");
}
and remote object is instantiated here:
<mx:RemoteObject id="mySample" destination="mySample" channelSet="{cs1}" fault="faultHandler(event)" />
But in event.fault
I get "Server.Processing" and event.faultString
equals "There was an unhandled failure on the server. Custom exception"
How can I receive the data is specified in exception props ?
BlazeDS log is similar to the log that was mentioned in the comment
[BlazeDS] 11:28:13.906 [DEBUG] Serializing AMF/HTTP response
Version: 3
(Message #0 targetURI=/2/onStatus, responseUR|-)
(Typed Object #0 ‘flex.messaging.messages.ErrorMessage’)
headers = (Object #1)
rootCause = null
body = null
correlationId = “2F1126D7-5658-BE40-E27C-7B43F3C5DCDD”
faultDetail = null
faultString = “Login required before authorization can proceed.”
clientId = “C4F0E77C-3208-ECDD-1497-B8D070884830?
timeToLive = 0.0
destination = “books”
timestamp = 1.204658893906E12
extendedData = null
faultCode = “Client.Authentication”
messageId = “C4F0E77C-321E-6FCE-E17D-D9F1C16600A8?
So the quesion is why rootClause is null? How can I get that Exception object not just a string 'Custom exception'?
© Stack Overflow or respective owner