The file exists

April 12, 2010

Maybe I should title this post ‘How to write a better error message’ instead.

I just went on a wild goose chase trying to find the solution to an error I kept seeing in SQL Server Management Studio every time I tried to run a query or open a table for editing (or anything else that would end up executing a SQL query).  The error message?

The file exists

Not exactly useful.

It turns out my temp directory was ‘full’.  The message sort of makes sense, now that I know what the problem was, but it isn’t really possible to draw the correct conclusion from that error message.

So two takeaways (for me):

  1. Craft error messages carefully.  The whole reason for showing/logging error messages in the first place is to create some kind of traceability to a problem.  The information contained in an error message should lead the user to a better understanding of the problem and possibly an indication of if they might be able to fix it.
  2. The file exists means clear your temp directory first, before chasing that goose.