Throw New Exception如何只显示自定义的信息?

rtsp 2005-03-23 10:09:18
vb.net项目,类输出为 xml ,并指定 xslt 模板,以显示网页

当数据验证或程序错误时,使用
Throw New Exception(message)
抛出异常

但是输出的文件 message 并不是指定的文字

而是

<message redirectto=''><![CDATA[调用的目标发生了异常。<br><br> at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
at EAXmlServer.DispatchCall()
at EAXmlServer.Page_Load(Object sender, EventArgs e)<br><hr><br>用户名不能为空,请检查您的输入<br><br> at **.**.**UpdateTableRows(String tableName, String strKeyName, String[,]& fields, String strDefaults)
at EASystem.BusinessFacade.SCR_sysAdmin_SuperUser.main()<br><hr><br>]]></message>

如何让message标签的内容只显示这个信息--“用户名不能为空,请检查您的输入”,谢谢
...全文
1312 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
kixs 2005-03-28
  • 打赏
  • 举报
回复
Throw New Exception("你想要的异常提示!")
xxuu503 2005-03-23
  • 打赏
  • 举报
回复
try
//你的代码
catch ex as exception
throw new exception("chucuole hehe")
end try
hamadou 2005-03-23
  • 打赏
  • 举报
回复

Throw New Exception("你想要的异常提示!")
rtsp 2005-03-23
  • 打赏
  • 举报
回复
处理后
While Not IsNothing(x)
strMessage += x.Message.Replace("\n", "<br>")
x = x.InnerException
End While

调用的目标发生了异常。用户名不能为空,请检查您的输入
---------------------
↑这些是没有的
landlordh 2005-03-23
  • 打赏
  • 举报
回复
test:

Try
Throw New Exception("用户名不能为空,请检查您的输入")
Catch ex As Exception
MsgBox(ex.Message)
End Try

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧