03-27-2014 12:23 PM
I've been working on an Error Handler library, culled mostly from these wonderful fora (Roberto!). I can't seem to find an error code string generator for the functions in the Utiltiy Library though (in particular, functions like RenameFile, CopyFile, GetDir, SetDir, MakeDir, all the file i/o functions).
Most of those make mention to negative error types with some plain text explanations. But there's no mention of a nice code-to-string converter function, as there is in other libraries. For instance, for the RS232 library, there is GetRS232ErrorString. For the Formatting & I/O library, there is GetFmtIOErrorString.
Am I not seeing it somewhere? Inside the Utility library, there is a multithreading error code function called CmtGetErrorMessage.
Solved! Go to Solution.
03-28-2014 05:00 PM
Greetings,
There doesn't seem to be a function in the Utility library just like the other ones you mentioned, but the following article may help in handling the errors yourself:
http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/programmerref/errorchecking/
And for the error codes themselves, you can search by function:
http://zone.ni.com/reference/en-XX/help/370051Y-01/cvi/libref/cviutility_library_function_tree/
Regards,
Brandon V.
Applications Engineer
National Instruments
03-31-2014 08:11 AM
Darn! I was afraid of that, just from my own exploration. I'm somewhat surprised. Seems like a big omission, given that most of the other libraries have their own string errorCode decoder.
Oh well, I'll make my own. Thanks.
03-31-2014 08:34 AM - edited 03-31-2014 08:37 AM
You're right: the Urility Library does not incorporate a function that translates error codes to a meaningful text. I suppose this is due to the fact that error codes partly overlap, so a unique function could not be used.
Just as an example, error -1 means File not found in almost all file I/O library functions, but it translates to No files found matching the search criteria in GetFirstFile () , to No more files in GetNextFiles () and Invalid Parameters in MakePathname ().
Another example: error -2 means GetFirstFile must be called before if returned by GetNextFile (), and Resulting pathname too long if returned by MakePathname ().
And this considering only File I/O section of the library!
While developing my own toolbox of utilities, I have created the following function, which I know is far from perfect and covers only file I/O functions:
char * CVIFUNC GetULibFileIOErrMsg (int error) // Messages associated to error codes returned by functions in File Utilities class in Utility Library { switch (error) { case 0: return "Success"; case -1: return "One of the path component not found"; case -2: return "Resulting pathname longer than 260 chars"; case -3: return "General I/O error occurred"; case -4: return "Insufficient memory to complete operation"; case -5: return "Invalid path"; case -6: return "Access denied"; case -7: return "Specified path is a directory, not a file"; case -8: return "Disk is full"; case -9: return "New file already exists"; default: return "Unknown error"; } return NULL; }