duanjuduo4573 2011-11-10 06: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 12: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/

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

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)