Redian新闻
>
The right way to create new Exception
avatar
The right way to create new Exception# Java - 爪哇娇娃
p*p
1
Sometime I need to catch a exception and create a new one,
} catch (oldException e) {
throw new newExcetion(e.getMessage());
}
e.getMessage() the right way to hand off exception information? Seem some
infor get lost after some jumps.
avatar
p*p
2
3ks ... one more question, getMessage and StackTrace, what is the difference
A cause can be associated with a throwable in two ways: via a constructor
that takes the cause as an argument, or via the initCause(Throwable) method.
New throwable classes that wish to allow causes to be associated with them
should provide constructors that take a cause and delegate (perhaps
indirectly) to one of the Throwable constructors that takes a cause. For
example:
try {
lowLevelOp();
} catch
avatar
g*s
3
initCause(Throwable cause)

exception

【在 p***p 的大作中提到】
: 3ks ... one more question, getMessage and StackTrace, what is the difference
: A cause can be associated with a throwable in two ways: via a constructor
: that takes the cause as an argument, or via the initCause(Throwable) method.
: New throwable classes that wish to allow causes to be associated with them
: should provide constructors that take a cause and delegate (perhaps
: indirectly) to one of the Throwable constructors that takes a cause. For
: example:
: try {
: lowLevelOp();
: } catch

avatar
p*p
4
3ks ... one more question, getMessage and StackTrace, what is the difference
A cause can be associated with a throwable in two ways: via a constructor
that takes the cause as an argument, or via the initCause(Throwable) method.
New throwable classes that wish to allow causes to be associated with them
should provide constructors that take a cause and delegate (perhaps
indirectly) to one of the Throwable constructors that takes a cause. For
example:
try {
lowLevelOp();
} catch
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。