Monday, 29 April 2013

Understanding error codes

Error messages frequently include error codes; sometimes they also include useful text that describes the code, but sometimes they don’t, leaving you to discover what the code means. Here's how I decipher CRM and Windows error codes.

CRM Error Codes
The CRM error codes are (reasonably) well documented here in the CRM SDK. If you’re searching for the code, one thing to watch for is that the code may be referenced with a prefix of 0x (which indicates the code is represented in hex) – e.g. 0x80040201. If you search for the code, it’s best to remove the 0x prefix.

It is also possible that you may receive the code as an integer (e.g. -2147220991). If you do, convert if to hex (I use the Calculator application), then search for it.
Windows Error Codes
There is more variation in how you may identify a Windows error code, but they are ultimately numerical values starting from 1, and (as far as I’m aware) are consistent across versions of Windows. Newer versions of Windows may include error codes that don’t exist in previous versions, but the same error code should have the same meaning across versions.

There is a quick and easy way to get the message associated with a given code – go to a command prompt and enter NET HELPMSG - e.g.
NET HELPMSG 5

And you’ll get the result
“Access is denied”

This is the message for error code 5 (which is probably the most common code I encounter, though I don’t keep stats on this…)
So, that’s fine if you’ve been given the error code as an integer value (I don’t know what the highest valued error code is – it’s probably either in the high thousands, or maybe 5 digits), but it’s not always that easy.

The code may be in hex(aka hexadecimal). If it contains one of the characters a-f, then it’s in Hex and you’ll need to convert it to decimal. I use the Calculator application to do this. Also, the value may be provided in hex but comes out just as digits. So, if I have an error code, and the message seems entirely irrelevant, I normally convert the code as if it were in hex to decimal, then pass it to NET HELPMSG.
The code may be in hex, but supplied as a 32-bit (or maybe 64-bit) integer with some higher bit flags set, for example:
80070005
0x80000002
&H80040035
The prefixes 0x and &H are some ways to indicate the value is in hex, and these prefixes can be discarded. You can also discard all but the last 4 characters (in these examples 0005, 0002 and 0035) and convert them from hex to decimal (in these examples giving 5, 2 and 53 respectively).


Finally, you may get a 32-bit integer with some higher bit flags set, receive the value in decimal, rather than hex. These almost always have the highest bit of a 32-bit value set, which means that in decimal they come out around 2 147 000 000 (or more commonly as a negative number, as they are typically signed integers). So, if I got an error code of -2147024891, I would:
  1. Convert it to hex, giving 80070005
  2. Discard all but the last 4 characters, giving 0005
  3. Convert it back to decimal, giving 5
  4. Run NET HELPMSG 5, and find that I’ve got another ‘Access is denied’ message

10 comments:

Unknown said...

Reading your article is such a privilege. It does inspire me, I hope that you can share more positive thoughts. Visit my website too. The link is posted below.axadsystem.com/advertising-management-software

graceedens said...

I enjoy it for your creating the article...keep it up guys!! thanks for sharing.....

office.com/setup
www.office.com/setup
Review my web blog

David Martin said...

I must appreciate this post as it provides the information regarding "Error codes".
Thanks for sharing this post with us.
office.com/setup

JACK said...

Such an essential information you have shared in this post. this will help many guys to learn more about Microsoft office

JACK said...

Such an essential information you have shared in this post. this will help many guys to learn more about Microsoft office. office.com/setup

williams said...

I read the blog about error codes. it is an important information you have shared with us. i must appreciate your work. office.com/setup

JACK said...
This comment has been removed by the author.
Jhonny Rampoon said...

Amazing work done. Nice website, Love it. Great website.
ij.start.cannon

Anonymous said...

Such a great post i think author of this site is good writer. keep writing

Download and install or reinstall office setup on a PC or Mac.

Steps to Install Office Setup using office.com/setup · Go to office.com/setup for Office Setup · Sign In to your Microsoft Office Account · Find your Office

Go to www.office.com/setup for Office Setup. Sign In to your Microsoft Office Account.Find your Office Product Key.Enter your Microsoft Office Product Key.

Officecom is a way where you can save you file in OneDrive and you can share and update online.

ross pearl said...
This comment has been removed by the author.