Javascript AngularJs中的异常处理
我已添加$exceptionHandlerJavascript AngularJs中的异常处理,javascript,angularjs,exception-handling,Javascript,Angularjs,Exception Handling,我已添加$exceptionHandler app.factory('$exceptionHandler', function () { return function (exception, cause) { alert(exception + cause); }; }); 我有一个服务 SomeService.save({ someaction : action,
app.factory('$exceptionHandler', function () {
return function (exception, cause) {
alert(exception + cause);
};
});
我有一个服务
SomeService.save({
someaction : action,
}, function(result) {
console.log(result)
}
)
设置异常消息的Java方法
@ExceptionHandler(IllegalStateException.class)
public ResponseEntity<String> handleRequest(Exception ex) {
return new ResponseEntity<String>(ex.getMessage(), HttpStatus.CONFLICT);
}
@ExceptionHandler(IllegalStateException.class)
公共响应HandlerRequest(例外情况除外){
返回新的ResponseEntity(例如getMessage(),HttpStatus.CONFLICT);
}
如果此服务抛出异常$exceptionHandler捕获异常,但异常消息显示意外令牌,而不是我在java方法中设置的错误消息