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/

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

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题