Update: A better version of the below code has been provied in another article. The new code gets both the error code and any restriction codes.
Errors
You are probably reading the error code incorrectly. I'm guessing that you are getting it from the Message text of an Exception that gets thrown when you make an API call. Although the Message usually contains the code, it's not the "correct" place to get it.
The correct thing to do is catch the SoapException, then check the Details property, which is a bunch of XML data. The Vault error code can be found between the <sl:errorcode> tags. Also, some errors will be accompanied by extra information in the form of a string array, found between the <sl:param> tags. Each parameter will have its own tag and "pid", which is an index value starting at 1. Most errors will not have extra parameters. See the Error Codes page in the API documentation for more information.
If you don't get a SoapException, it means that the error is not coming from the Vault server. Something else is causing the error, such as a network error.
Restrictions
Restrictions can be thought of as extended error information. In the case of an Exception from the Vault server, there is one and only one error code. Restrictions, however, can have multiple codes. This is useful for complex operations where multiple things can fail at once, and you want to display everything to the user in a single dialog.
If the error code is 1092, 1387, or 1633, then you need to examine the restriction information to find out what the problem is. For all other errors, there is no restriction information.
Just like with errors, you need to examine the Details XML in the Soap Exception. The Restriction Codes page in the API documentation has more information.
Sample Code
Here is the correct way to read the error code.
C#:
public static string GetErrorCodeString(Exception e) |
VB:
Public Shared Function GetErrorCodeString(ByVal e As Exception) As String |