自定义异常并解析异常消息
ex.Message = "ORA-20586: SOME TEXT SOME TEXT.\nORA-06512: at \"RMM.LOKAC\", line 116\nORA-06512: at line 2"
catch (Exception ex)
MessageBox.Show(ex.Message);
return false;
}
ex.Message = "ORA-20586: SOME TEXT SOME TEXT.\nORA-06512: at \"RMM.LOKAC\", line 116\nORA-06512: at line 2"
但我需要得到“一些文本一些文本”。我怎样才能只阅读文字。
ORA-20586 表示用户错误http://www. dbmotive.com/support/oracle-error-codes/?type=ORA&errcode=20586
数据库是 Oracle。我怎样才能从这个错误消息中读取“SOME TEXT SOME TEXT”。
ex.Message = "ORA-20586: SOME TEXT SOME TEXT.\nORA-06512: at \"RMM.LOKAC\", line 116\nORA-06512: at line 2"
catch (Exception ex)
MessageBox.Show(ex.Message);
return false;
}
ex.Message = "ORA-20586: SOME TEXT SOME TEXT.\nORA-06512: at \"RMM.LOKAC\", line 116\nORA-06512: at line 2"
but i need to get just "SOME TEXT SOME TEXT". How can i read just text.
ORA-20586 means user error http://www.dbmotive.com/support/oracle-error-codes/?type=ORA&errcode=20586
Database is Oracle. How can i read just "SOME TEXT SOME TEXT" from this error message.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
提取字符串的方法有很多种。您可以尝试字符串拆分、正则表达式拆分或字符串索引搜索。
There are number of ways to extract the string. You may try String split, regular expression split or string index search.
最好捕获异常,然后编写更用户友好的消息。如果可能的话,您永远不想暴露应用程序的底层架构。
It is always better to catch the exception, then write a more user friendly message. You never want to expose the underlying architecture of your application, if possible.