我想将错误代码关联到异常。
在此链接中http://www.restapitutorial.com/httpstatuscodes.html我们可以找到 HTTP 状态代码。
Java 异常代码有任何类型的约定,例如 EJBException?
最佳答案
没有。没有将错误代码附加到异常的约定。
您可以轻松地编写自己的Exception
来执行此操作:
public class MyAppException extends Exception
{
private String errorCode;
public MyAppException(String errorCode, String message)
{
super(message);
this.errorCode = errorCode;
}
// errorCode getter & setter
}
关于java - 约定 Java 错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26037807/