`
jzzwy
  • 浏览: 103045 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

There was an unhandled failure on the server

阅读更多

在Spring BlazeDS Integration 集成环境中,我们尝试抛出以下自定义异常

	public void remove() throws Exception {
			try {
				throw new LmxException("删除失败!");
			} catch (LmxException e) {
				throw e;
			}
	}
	

  
  在Flex端是这样捕获的

private  function operateFaultHandler(event:FaultEvent):void{ 
var exception:LmxException = event.fault.rootCause as LmxException; 
Alert.show(exception.message,"提示"); 
} 


 

   
但是抛出了There was an unhandled failure on the server.Spring BlazeDS Integration 的原文DOC如下。小弟英语不好,

简单翻译几句,服务器端抛出异常时,为了让Flex端获取到更为友好的信息,原始的异常的信息必须能够被解析成MessageException类的实例

2.8. Using Custom Exception Translators

In order to propagate useful information back to the Flex client when an exception occurs on the server, the original exception must be translated into an instance of flex.messaging.MessageException. If special translation logic is not applied, a generic "Server.Processing" error will propagate to the client that doesn't give the client the chance to reason on the real cause of the error to take appropriate action. Special exception translators are configured by default for transforming Spring Security exceptions into an appropriate MessageException, but it could also be useful to provide custom translation for your own application-level exceptions.


Custom exception translation logic can be provided through implementations of the org.springframework.flex.core.ExceptionTranslator interface. These implementations must be configured as Spring beans and then registered through the XML configuration namespace as follows:


  自定义异常解析逻辑可以由实现ExceptionTranslator 的接口实现,这些实现类必须按照以下的配置,LmxException 是自定义异常类

public class ExceptionTranslatorImpl implements ExceptionTranslator { 

@Override 
public boolean handles(Class> clazz) { 
// TODO Auto-generated method stub 
return Boolean.TRUE; 
} 

@Override 
public MessageException translate(Throwable throwable) { 
// TODO Auto-generated method stub 
MessageException messageException = null; 
if (throwable != null) { 
if (throwable instanceof LmxException) { 
messageException = new MessageException(); 

LmxException lmxException = new LmxException(); 
lmxException.setMessage("异常"); 
messageException.setRootCause(lmxException); 
} 
} 
return messageException; 
} 
} 
<!-- Custom exception translator configured as a Spring bean -->
<bean id="myExceptionTranslator" class="com.foo.app.MyBusinessExceptionTranslator"/>

<flex:message-broker>
	<flex:exception-translator ref="myExceptionTranslator"/>
</flex:message-broker>   

 

分享到:
评论

相关推荐

    关于Unhandled event loop exception No more handles的两种解决方案

    ### 关于Unhandled event loop exception No more handles的两种解决方案 在使用Eclipse开发工具的过程中,有时会遇到一个较为棘刺的问题——出现“Unhandled event loop exception No more handles”的错误提示。...

    AviWriter 带demo

    a compressed file, or an unhandled exception. The only way to prevent it, that I see, is, to collect more peculiarities about the codecs and stop execution in case of certain combinations of settings....

    Office 2003 组件owc11

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace ...

    BobBuilder_app

    RaptorDB starts off by loading the page list and it is good to go from there and pages are loaded on demand, based on usage. Page Splits In the event of page getting full and reaching the ...

    NTGraph测试程序(有问题)

    for infomation on how your program can cause an assertion failure, see the visual c++ documentation on asserts 最后跳出: Unhandled exception in controltest2.exe(mfc42d.dll):0xc0000005:access ...

    DotfuscatorPro_4.9.7000

    Assembly-level Unhandled ExceptionTrackAttributes on ASP.NET applications no longer cause build errors. Corrects an issue where XNA phone apps could have been misidentified as Silverlight apps during ...

    plsqldev12.0.6.1832x32主程序+ v12中文包+keygen

    Clicking on an item will show the text with syntax highlighting in the preview pane, and will show the timestamp above the preview pane. Double-click on an item to paste the text in the cursor ...

    plsqldev12.0.6.1832x64主程序+ v12中文包+keygen

    Clicking on an item will show the text with syntax highlighting in the preview pane, and will show the timestamp above the preview pane. Double-click on an item to paste the text in the cursor ...

    PLSQL.Developer(X32) v12.0.1.1814主程序+ v11中文包+keygen

    Clicking on an item will show the text with syntax highlighting in the preview pane, and will show the timestamp above the preview pane. Double-click on an item to paste the text in the cursor ...

    plsqldev12.0.4.1826x32主程序+ v12中文包+keygen

    Clicking on an item will show the text with syntax highlighting in the preview pane, and will show the timestamp above the preview pane. Double-click on an item to paste the text in the cursor ...

    global.asax

    // Code that runs when an unhandled error occurs } void Session_Start(object sender, EventArgs e) { // Code that runs when a new session is started } void Session_End(object sender, ...

    Node.js-在Electron应用中捕获未处理的错误和promiserejections

    console.error('An unhandled error occurred:', error); }, dialogOptions: { type: 'error', buttons: ['Close', 'Stay Open'], defaultId: 1, title: 'An error occurred', message: 'An unhandled error...

    PLSQL.Developer(X64) v12.0.1.1814 主程序+ v11中文包+keygen

    Clicking on an item will show the text with syntax highlighting in the preview pane, and will show the timestamp above the preview pane. Double-click on an item to paste the text in the cursor ...

    plsqldev12.0.4.1826x64主程序+ v12中文包+keygen

    Clicking on an item will show the text with syntax highlighting in the preview pane, and will show the timestamp above the preview pane. Double-click on an item to paste the text in the cursor ...

    Eclipse运行TOMCAT 出现在a java exception has occurred的解决办法。

    当我们在Eclipse中双击TOMCAT SERVER时,可能会出现"a java exception has occurred"的错误信息,这是因为Eclipse无法找到TOMCAT的类库文件tomcat-ujli.jar所致。tomcat-ujli.jar是TOMCAT的核心类库文件,负责处理...

    ASP.NET The system cannot find the file specified解决办法

    ASP.NET The system cannot find...Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where

    Diskeeper 2008 v12.0.759.0

    relies heavily on the MFT and paging file, the effect of fragmentation is often much greater than when a normal file is fragmented. The Frag Shield feature keeps your MFTs defragmented ...

    SQL Prompt_9.1.3.4467破解版

    SP-6859, SP-6860 : Code analysis no longer causes an unhandled exception when scanning unparsed T-SQL. SP-6861 : Code analysis no longer causes an unhandled exception when dealing with variable ...

    a freeware C++ class and DLL which intercepts and logs details about unhandled exceptions

    记录程序崩溃时异常时的日志信息。... The class was originally based upon the February 2002 MSDN article called "Under the Hood: Improved Error Reporting with DBGHELP 5.1 by Matt Pietrek.

    SCJP 6 question demo

    Based on the given content from the SCJP 6 question demo, we can extract several important IT knowledge points related to Java programming, particularly focusing on threading and synchronization ...

Global site tag (gtag.js) - Google Analytics