This is a small C code that just converts a erronum to a piece of text. You could probably write it faster than checking it out.
perror exits on many machines these days to do this. I wrote this aling time ago. May I also recommend perror from mysql for looking up mysql codes as well as standard system codes.