0
我正在尋找一種方法來捕獲由PHP在Flex中使用HTTPService
引發的異常。沒有使用AMFPHP可以嗎?在沒有AMFPHP的Flex中捕獲PHP異常
在我當前的實現中,如果在PHP中引發異常,則確實在Flex側調度了FaultEvent.FAULT
。唯一的問題是在FaultEvent
中找不到異常的消息字符串。
讓我試着在一個例子的幫助下更好地解釋。讓我們說我們有服務器端下面的PHP代碼:
<?php
throw new Exception("Exception message");
?>
在柔性的一面,說有一個HTTPService
實例,它調用上面的PHP代碼。此外,它呼籲FaultEvent.FAULT
以下功能:
private function onFaultyResult(evt:FaultEvent):void {
//How do I get the exception message here?
}
我怎麼能在這個函數得到PHP異常消息?
注:trace(evt.toString())
給出:
[FaultEvent fault=[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: 192.168.1.119/exception.php"]. URL: 192.168.1.119/exception.php"] messageId="7FF021A3-8C83-CB14-081D-8C8438802204" type="fault" bubbles=false cancelable=true eventPhase=2]
我也看了中的調試器evt
等領域「異常信息」,但無法找到它。
謝謝
RTFM:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript /3/mx/rpc/events/FaultEvent.html –
@nikc:這是trace(evt.toString)顯示的內容: [FaultEvent fault = [RPC Fault faultString =「HTTP請求錯誤」faultCode =「Server.Error。請求「faultDetail =」錯誤:[IOErrorEvent type =「ioError」bubbles = false cancelable = false eventPhase = 2 text =「錯誤#2032:流錯誤。 URL:http://192.168.1.119/flex_ssh2_exception.php「]。URL:http://192.168.1.119/flex_ssh2_exception.php」] messageId =「07CC2B64-D064-8EB3-CF6D-8C74D4BE7125」type =「fault」bubbles = false cancelable = true eventPhase = 2] –