I need to know how to get a specific section of an message generated by an exception in java, in debug mode, I have obtained the value I need, which attached image, but I need get that data in the code to generate a "Switch", I require something like this:
try
{
processes ....
} catch (SQLException ex) {
string reason = ex.**(how to get the failure reason)**;
switch (reason) {
case "_bt_check_unique":
JOptionPane.showMessageDialog (null, "Error, the record already exists.");
break;
}
您将要在异常对象上调用getStackTrace()
,然后在返回的数组中的StackTraceElement
对象上使用各种getter方法。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.