Convert Error Code To Text
Contents |
specialises, amongst other things, in large-scale deployments of Microsoft Windows using technologies such as BDD2007 and the Microsoft Deployment Converting Windows Error Codes To Something More Friendly ★★★★★★★★★★★★★★★ doxleyNovember
Hexadecimal Error Codes
5, 20090 0 0 0 I can never remember how to do this, formatmessage so I always end up looking it up. Therefore, I am posting it here partly for me as a strerror example reference, but also in case anyone else finds it useful 🙂 Sometime the error codes that are returned by Microsoft Windows are accompanied by a rather cryptic message, or the message
Win32 Error Codes
doesn’t quite offer enough information to be able to work out what has happened. Well, if you follow the steps below you can look up what the message means to Windows, based on the error code that was returned. Make note of the last four numbers of the hexadecimal error code, in this example it is 2AFC. Open the Windows Calculator (calc.exe) and
Getlasterror
switch it to the Scientific mode (or Programmer mode if you are using Windows 7). Select the Hex radio button, then enter the last four digits of the hexadecimal error number. Select the Dec radio button, and you’ll see the hexadecimal number converted to a decimal one. Open a command prompt (cmd.exe) and type the following command: “NET HELPMSG ” followed by the decimal number that appears in the calculator. In this case, the command would be: “NET HELPMSG 11004”. You will then be returned what is hopefully a more friendly version of the error message. Note that this will only work for Win32 error codes that originate from Microsoft Windows, the codes will often start with 8007 but not always. Also, if the net helpmsg command does not return a result it most likely means that the error either did not originate from Windows, or is not a valid Win32 process. Tags Tips Windows Comments (0) Cancel reply Name * Email * Website Follow UsPopular TagsWindows Tips Vista Windows 7 Hyper-V Misc Server 2008 Scripting Office XP Security Windows Live Microsoft Deployment Toolkit Server 2008 R2 Business
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us windows error codes Learn more about Stack Overflow the company Business Learn more about hiring developers or
Errno
posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow hresult Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How to convert errno in UNIX to corresponding string? https://blogs.technet.microsoft.com/doxley/2009/11/05/converting-windows-error-codes-to-something-more-friendly/ up vote 33 down vote favorite 3 Is there any function in UNIX to the convert errno to its corresponding string for e.g. EIDRM to "EIDRM". Its very annoying to debug to check for errors with these integer errnos. unix errno share|improve this question asked Oct 10 '09 at 2:38 avd 3,953195982 add a comment| 5 Answers 5 active oldest votes up vote 59 down vote accepted http://stackoverflow.com/questions/1546882/how-to-convert-errno-in-unix-to-corresponding-string strerror() should do it. http://linux.die.net/man/3/strerror FYI, so that you can find these things more easily, yourself: If you type man errno (or whatever function you're investigating), and look at the very bottom of the man page, you'll see a list of related functions. If you man each of those (taking a guess about which one(s) to do first based on their names) you'll often find the answer to similar questions. share|improve this answer answered Oct 10 '09 at 2:45 atk 6,68521931 1 strerror will actually turn them into much more useful strings than just "EIDRM" as the op asked, but that's the answer I would have given too. –Paul Tomblin Oct 10 '09 at 2:48 those strings are actually not that useful, because the man pages for the system calls often specify error behaviors in terms of the enum code. The string is at best a hint. –orm Jan 6 at 21:05 Danger, Will Robinson! strerror()'s strings are localised, as I found out when I was checking an error string for "No such file or directory" but my user's platform was returning "Arquivo ou diretório nao encontrado" instead. (This was in a language where the e
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with http://stackoverflow.com/questions/3975313/translate-error-codes-to-string-to-display us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Translate error codes to string to display up vote 4 down vote favorite 2 Is there a common way in C++ to translate an error code to a string to display it? I saw somewhere a err2msg function, with a big switch, but error code is that really the best way? c++ share|improve this question asked Oct 20 '10 at 6:38 Karl von Moor 5,71212445 Where does your error code come from ? Custom or system ? –ereOn Oct 20 '10 at 6:41 2 What error codes. From a library from the standard library from an api. –rerun Oct 20 '10 at 6:42 In my project I'm returning error codes from functions, like ERR_OK, ERR_RT_OUT_OF_MEMORY, ERR_OBJECT_NOT_FOUND etc. These I'd like to translate to string convert error code –Karl von Moor Oct 20 '10 at 6:43 Certainly, but have you defined those error codes yourself or do they come from elsewhere ? –ereOn Oct 20 '10 at 6:45 @ereOn I've defined them myself :) –Karl von Moor Oct 20 '10 at 6:47 add a comment| 7 Answers 7 active oldest votes up vote 8 down vote accepted Since C++ does not allow automatic 'translation' from enum values to enum names or similar, you need a function to do this. Since your error codes are not somehow defined in your O/S you need to translate it by yourself. One approach is a big switch statement. Another is a table search or table lookup. What's best depends on error code set. table search can be defined in this way: struct { int value; char* name; } error_codes[] = { { ERR_OK, "ERR_OK" }, { ERR_RT_OUT_OF_MEMORY, "ERR_RT_OUT_OF_MEMORY" }, { 0, 0 } }; char* err2msg(int code) { for (int i = 0; error_codes[i].name; ++i) if (error_codes[i].value == code) return error_codes[i].name; return "unknown"; } share|improve this answer edited Oct 20 '10 at 7:52 sbi 134k34174348 answered Oct 20 '10 at 6:57 harper 8,45342867 +1, I like the syntax you used. –Merlyn Morgan-Graham Oct 20 '10 at 7:02 3 If your error codes are consecutive then you can use just array of strings instead of array of structs. So you can access to the error string by index. Keep the number of errors to check array bounds.