1
我正在使用Flex + Blazeds + Spring Security。我的ExceptionTranslator有一些奇怪的事情發生。異常來自ExceptionTranslator不返回到flex
public class ProjectExceptionTranslator implements ExceptionTranslator {
@Override
public boolean handles(Class<?> arg0) {
return true;
}
@Override
public MessageException translate(Throwable throwable) {
MessageException exception = new MessageException();
if (throwable instanceof BadCredentialsException) {
exception.setCode("08");
exception.setMessage("Login error.");
}
if (throwable instanceof HibernateException) {
exception.setCode("16");
exception.setMessage("Data base error.");
}
return exception;
}
}
春天拋出,前全部消息:BadCredentialsException,返回彎曲。但是如果我的服務拋出一些例如HibernateException,它不會返回到flex。
這是我的配置:
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<flex:message-broker>
<flex:exception-translator ref="projectExceptionTranslator" />
<flex:secured />
</flex:message-broker>
我缺少的東西?謝謝。
您是否使用Spring Framework進行依賴注入?如果這是真的,那麼你的HibernateException可能會被包裝到合適的Spring異常中。 –
@MaksymDemidas你說得沒錯,但我仍然可以用上面的代碼捕獲數據庫錯誤。所有異常都由ProjectExceptionTranslator處理,我的問題是當我返回這個異常。這個異常不會回到flex,它會以某種方式丟失。 – raonirenosto