When trying to resolve a problem it is often necessary to post something like a stack trace or the error text you receive from the system.

However, such stack traces can become quite lengthy.
What would be the better way to post them?

I have seen it formatted better (with horizontal scrolling) in some other questions, but I have no idea on a way to find those questions again to look at their source.

Also searching on anything with the word "stack" in it is utterly useless on meta as you will only find references to SO itself.


Edit: Generally you should format the stack trace with the Code Sample markdown formatting, or using <pre></pre> or <code></code> HTML tags. I think the main difference is that the markdown attempts to apply some syntax coloring to the text, but I think there are some circumstances where the markdown formatting works better than the HTML.

Edit 2: I've since figured out that while syntax coloring doesn't happen with <pre> or <code> HTML tags by themselves, using both does do syntax coloring: <pre><code> foo </code></pre>

Original: If your stack trace is long enough that readability is a concern, you could use Pastebin. It's a bit like an image-hosting site, for text snippets.

Or you could pare your stack trace down to bare essentials (say, 10 lines or less -- or some other limit for readability).

Or you could combine the two: post the 10 most significant (to your eye) lines; post a link to the full trace on PasteBin; and if others point out more significant lines, edit your post accordingly.

  • Good idea. Yet I was more interested in the correct markdown syntax – Boris Callens Dec 8 '09 at 12:07
  • 1
    ah. i think "correct" markdown syntax is the obvious "code" formatting; you could also use <pre></pre> tags. i thought your question was more concerned with the length. – quack quixote Dec 8 '09 at 12:13
  • ah, the pre tag is doing what I needed – Boris Callens Dec 8 '09 at 13:23
  • ok, touched up the answer to include that. – quack quixote Dec 8 '09 at 14:05
  • 1
    It might be useful to explicitly mention pastebin as an alternative to inlining a whole bunch of content (although I know no one ever reads posting instructions..) :) – Ether Dec 8 '09 at 19:43
  • @Æther: not a bad suggestion; post as a feature-request or faq-enhancement-request or some such and i'll vote it up. – quack quixote Dec 9 '09 at 5:27
  • 3
    If you do use pastebin, make sure to set the expiration time on it to never. By default, it will get deleted after a month, then we'll have a worthless question with a broken link. – TM. Dec 28 '09 at 7:05
  • @TM: ooo, thanks for the tip. i'm still new to the pastebin phenomenon, the nuances are lost on me atm. – quack quixote Dec 28 '09 at 14:44

Good question, and thank you for thinking of this.

Try mightily to post just the relevant bits of the code -- you will get better answers if you limit the amount of reading people have to do.

There's nothing more offputting and intimidating than trying to read a question which is little more than a giant wall of code.

(In extreme cases, it also feels a bit like "do my work for me", as well..)

  • Yes, I always try to work in that spirit. Sometimes however you don't have a clue what the actual problem is and have no option then to dump everything you know in there and see if anybody can get you on the right track. In that case the "external code" part is excellent. – Boris Callens Dec 28 '09 at 11:06

You must log in to answer this question.

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