Does anyone have any tips on how to create a user readable error/warning code message?
I have been struggling to try and figure out a way of doing this that is not a case statement that has to be created for each of the error definitions I need.
After something similar to visual studio Exception.Message
Example:
- swFileSaveError_e(1) = "Generic save error"
- swFileSaveError_e(4) = "Filename cannot be empty"
Hi Michael!
I've been there
Make a static helper method that converts the name of the enumrator to a string. Remove the "sw" and add a space after every capital letter. That's the easiest most convenient way to do it.
Your second example: swFileNameEmpty -> File Name Empty. That should be enough to describe the error.
If you really really want to get the enumrator's description off the help file. You can construct the api online help url from the name of the enumaration name:
help.solidworks.com/2013/English/api/swconst/SolidWorks.Interop.swconst~SolidWorks.Interop.swconst.ENUMERATIONNAME.html
Then you'll need a html processing library to be able to retrieve the DOM element that contains the enumrator's description. I do feel that this can be an overkill though.
Best,
Amen
CADHero.com