Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line-breaks in Exception.Message

I'm extending Exception to implement a setter on the Message property. And this works just fine. But somehow this:

CustomException.Message = "Test" + Environment.NewLine + "Test Again";

Becomes this:

"Test\r\nTest Again"


I've also tried this, with no luck:

CustomException.Message = @"Test

Test Again";


Any ideas?

like image 254
cllpse Avatar asked Sep 10 '09 10:09

cllpse


People also ask

What is a line break in text?

line break (plural line breaks) (typography) A point in writing where text that would normally continue on the same line starts at the beginning of a new line. (computing) A character indicating that subsequent characters should appear on a separate line of text; newline, line feed.

What does exception message mean?

An exception occurs when a package or shipment encounters an unforeseen event, which could result in a change to the expected delivery day. Examples of exception include: address unknown, damage to shipment, or signature not received.

How do I show an exception message?

Following are the different ways to handle exception messages in Java. Using printStackTrace() method − It print the name of the exception, description and complete stack trace including the line where exception occurred. Using toString() method − It prints the name and description of the exception.

Which command is used for line break?

<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division of lines is significant.


2 Answers

Environment.NewLine IS \r\n (at least on Windows, anyway...)

like image 101
wefwfwefwe Avatar answered Oct 05 '22 20:10

wefwfwefwe


\r\n characters will be converted to new line when you display it by using message box or assign it to text box or whenever you use it in interface.

like image 28
Wael Dalloul Avatar answered Oct 05 '22 19:10

Wael Dalloul