0

I want to throw an exception in asp.net VB web application using framework 2.0 my issue is I only want to show the error message , but using below code i also see line number, file and other error messages.

Throw New ApplicationException("My error message ")

i have tried the below code

Throw New ApplicationException("Insert Member Method Not Supported")

 Throw New ApplicationException("Insert Member Method Not Supported")

I want to show My error message without line numbers or file name that it is in etc using Throw New ApplicationException() or an alternative that halt's further operation and displays a error message

user3548161
  • 119
  • 5
  • 18
  • Possible duplicate of [How to display an error message in an ASP.NET Web Application](https://stackoverflow.com/questions/651716/how-to-display-an-error-message-in-an-asp-net-web-application) Or [this](https://stackoverflow.com/q/38344186/4934172) for VB. – 41686d6564 stands w. Palestine Jun 19 '19 at 05:09
  • That other information is called a "stack trace". Is there any reason why you don't want to see this? – ProgrammingLlama Jun 19 '19 at 05:09
  • I'm delivering data to a third party legacy fronted that doesn't do any handling for some reason. My only option is to manually throw an error to send across an exception message eg " Incorrect password" – user3548161 Jun 19 '19 at 05:12
  • at Ahmed , That example doesnt help me understand how can i raise a manual exception y self like Throw New ApplicationException("Insert Member Method Not Supported") and than show it without stack trace. – user3548161 Jun 19 '19 at 05:13
  • @user3548161 I assumed you can handle the exception (i.e., try-catch) somewhere else in the code (or in the front-end). Why can't the exception be handled in the front-end? When an exception is thrown, it has one of two paths: either get handled or cause the application to crash. – 41686d6564 stands w. Palestine Jun 19 '19 at 05:17
  • ahmed I know how to use try catch normally but i dont know when using Throw New ApplicationException("Insert Member Method Not Supported") can you give example – user3548161 Jun 19 '19 at 07:58

0 Answers0