Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

In StackOverflow, I often see users posting long errors messages (or Exception stacktraces). Is there any correct way of formatting this kind of thing on StackExchange sites ?

Code ? :

[ERROR] Line 38: No source code is available for type; did you forget to inherit a required module?

Blockquote ? :

[ERROR] Line 38: No source code is available for type; did you forget to inherit a required module?

Plain ? :

[ERROR] Line 38: No source code is available for type; did you forget to inherit a required module?

share|improve this question
Code, with <!-- language: lang-none --> to turn syntax highlighting off, I'd say. – Daniel Fischer Jul 27 '12 at 11:23
@DanielFischer, I asked myself if that would be the correct way. However, the language tag specifies software code right ? IMHO, from a semantic point of view, that's not correct for stacktraces. – Jean-Michel Garcia Jul 27 '12 at 11:28
Well, you need to keep the linebreaks, or the message becomes unreadable. Thus a blockquote is wrong, as is plain. You could try <pre>, but directly using HTML tags is, as far as I know, frowned upon somewhat. – Daniel Fischer Jul 27 '12 at 11:33
@DanielFischer, you should write an answer, rather than commenting. Your line break argument is valid, and therefore I would like to mark this as an answer – Jean-Michel Garcia Jul 27 '12 at 11:47
up vote 13 down vote accepted

To keep the stack traces/error messages readable, line breaks need to be preserved, since they have meaning in such messages.

Although it is possible to insert line breaks into plain text or blockquotes by ending each line with two spaces, that is a lot of work for longer traces.

A further point is that - in my opinion - a monospaced font makes such messages more readable than a proportional font.

Thus my preferred solution is a code block, with syntax highlighting turned off by a <!-- language: lang-none --> hint before the code block.

share|improve this answer
Using <!-- language: lang-none --> turns off highlighting, but it gets displayed. I would expect it is hidden. – dzieciou Jan 22 '13 at 15:29
@dzieciou I never saw it getting displayed. Perhaps you put it in the wrong place? The HTML comment should not be indented, and separated from the code block it applies to by a blank line. – Daniel Fischer Jan 22 '13 at 15:35
Yep, it was a matter of place. Thanks. – dzieciou Jan 22 '13 at 15:37
If you are doing this on your own site and using highlightjs then set class="no-highlight". – ShitalShah Apr 11 '14 at 1:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .