7

Error messages are a fairly common thing to mention, in both questions and answers, across many Stack Exchange communities. I think it would be valuable to have a markdown syntax to denote error messages in a manner that is visually distinct from the other offerings. I am fully aware of the current options to use either a blockquote (i.e. > syntax) or generic code block (i.e. either ``` with no specified language, or indented with <!-- language: lang-none --> ), and have been using both for 9 years now. Still, I believe that these two approaches are just work-arounds, making the best of what is available because what is ideal is not available.

Error messages are not quotes. I quote documentation, books, articles, people, and sometimes output / results fit well-enough into this.

Error messages are not code. I think we all agree on this, and so a generic / non-highlighted code block is often the reasonable approach as the fixed / monospace font plus preservation of whitespace lends itself well to this purpose. BUT, while this might be a better option than the blockquote, a generic code block should be for code that doesn't have a syntax highlighter, command-lines, occasionally output / results, etc.

Error messages are something else and should stand out. They are even handled separately at the OS / shell / code level (i.e. stdout vs stderr). A code block would suffice as long as it was obviously different than other code blocks. Perhaps all text in red and/or a red border? And maybe the syntax could be something like:

``` error
Msg 50505, State 10, Level 42
A horse is a horse,
of course of course
```

P.S. This question comes up from time to time, but I don't believe it has ever gotten a satisfactory answer. For example:

  1. Correct way to format errors messages (or stacktraces)
  2. There should an extra “code” type for error message
  3. Formatting Returned Errors on Stack Overflow Questions
  4. Best way to denote an error message?
  5. Proper syntax highlighting for compile errors / output?
5
  • I think this very much depends on the language you are coding in. I could imagine that for certain languages syntax highlighting would be beneficial in an error message. While in other syntax highlighting could be confusing. Also I don't agree with your premise that it is not a quote. I quote the error message from the software, so in most cases a quoteblock is a perfect way of formatting an errormessage.
    – Luuklag
    Jun 19, 2020 at 6:45
  • 1
    I sometimes use a code block, with syntax highlighting style set to None, inside a blockquote. But I think a generic Error syntax highlighting style could work, eg all text in dark red.
    – PM 2Ring
    Jun 19, 2020 at 6:55
  • @Luuklag Thanks for the feedback. 1) Sure, while some languages might benefit from syntax highlighting, I don't see that as being feasible to implement, and so it made more sense to request a standard approach that would at least be identifiable to most readers, even if not a near-perfect replica of the actual error message. 2) Yes, in a generic sense error message are "quoted" just like anything else because we are duplicating them here, but my point is that the nature of an error message is not the same as regular output, and hence it should be easier for readers to distinguish between them. Jun 19, 2020 at 7:07
  • @Luuklag Well that's part of the problem isn't it, that people disagree on whether quote formatting or error code formatting should be used for errors? Personally, I don't think it makes sense to use quote formatting when no one is saying anything (especially for something you can't actually write a citation for). It also just looks terrible for error messages designed for monospaced fonts.
    – BSMP
    Jun 19, 2020 at 17:01
  • There's a workaround if you want to at least bold the error message in code block Jun 21, 2020 at 15:38

0

You must log in to answer this question.