Multiple lines for exception message

  • Thread starter Thread starter Chris Leffer
  • Start date Start date
C

Chris Leffer

Hi.

I have a function that raises a custom exception message. I am trying to
divide the message in 3 lines, but could not successfuly display the
message. Those were my tries:

Throw New IndexOutOfRangeException("Error converting the text.
Possibilities are:" & ControlChars.NewLine & "- Text is too long." &
ControlChars.NewLine & "- Text is empty.")

Throw New IndexOutOfRangeException("Error converting the text.
Possibilities are:<br>- Text is too long.<br>- Text is empty.")

How van I create an error message with multiple lines? Can anyone help
me with this?

Regards,
Chris Leffer
 
You would find the formatting only when you display the exception message on
the page. Try the following. You would find the format in effect.
try
{
throw new IndexOutOfRangeException("Error converting the text. Possibilities
are:<br>- Text is too long.<br>- Text is empty.");
}
catch(IndexOutOfRangeException ex)
{
Label1.Text=ex.Message;
}
 
Back
Top