我应该生成异常消息(在我的示例中来自link
参数)还是我的构造函数应该接受message
参数?
class ReadFromNotConnectedInputException extends RuntimeException {
private String link;
public ReadFromNotConnectedInputException(final String link)
{
this.link = link;
}
public String getLink()
{
return link
}
public String getMessage()
{
return String.format("Cannot read from link \"%\", link not connected.", link);
}
}