duanjuduo4573 2011-11-09 22:43
浏览 51
已采纳

在没有AMFPHP的情况下在Flex中捕获PHP异常

I'm looking for a way to catch an Exception thrown by PHP in Flex using HTTPService. Is it possible to do it without using AMFPHP?

In my current implementation, if an Exception is thrown in PHP, a FaultEvent.FAULT is indeed dispatched on Flex side. The only problem is that the exception's message string is nowhere to be found in FaultEvent.

Let me try to explain better with the help of an example. Let us say we have the following PHP code on server side:

<?php
  throw new Exception("Exception message");
?>

On flex side, say there is an HTTPService instance which calls the above PHP code. Moreover, it calls the following function on FaultEvent.FAULT:

private function onFaultyResult(evt:FaultEvent):void {
  //How do I get the exception message here?    
}

How can I get the exception message from PHP in this function?

Note: trace(evt.toString()) gives:

[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]

I also looked for "Exception message" in other fields of evt in the debugger but couldn't find it.

Thank you

  • 写回答

1条回答 默认 最新

  • douxuanwei1980 2011-11-10 04:43
    关注

    The root problem is that Flash can't handle server retuns a status <> 200 http://www.robsondesign.com/blog/index.php/2009/04/16/flex-flash-and-http-status-codes/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部