Exception 处理应用程序中的异常
在我的应用程序中,需要以两种方式处理异常:Exception 处理应用程序中的异常,exception,Exception,在我的应用程序中,需要以两种方式处理异常: 可以由前台处理 Try { //code } catch(Exception ex) { Exception("Contact Admin"); } 向用户显示用户友好的准确错误消息,该消息可由用户自己处理 Try { enter code here } Catch(Exception ex) { `code here` } 如何在应用程序中实现第二种方式?我之
Try
{
//code
}
catch(Exception ex)
{
Exception("Contact Admin");
}
Try
{
enter code here
}
Catch(Exception ex)
{
`code here`
}
如何在应用程序中实现第二种方式?我之前看到的方式如下:
MyExtendedObject o = new MyExtendedObject();
try {
// do your processing
o.setValue(...);
return o;
} catch (Exception e) {
log.error(e);
o.addErrorMessage("The processing has been unable to complete, please try again");
// getValue() will be empty for the front-end.
return o;
}