Handling errors returned by Tachyon
This section describes how the Tachyon Consumer API shows errors.
What does the Consumer API return when an error happens?
An HTTP call will result in a response message with a payload and HTTP status code. Usually, 4XX and 5XX codes represent errors, with 4XX range being errors made by the calling user (for example, incorrect payload or wrong URI) and 5XX errors on the server itself. The payload of the response message is a JSON array. Each element of that array is an Error object described in the next section.
The Error object
The Error object has 3 properties:
ErrorCode - the internal Tachyon error code described in error code
Message - a localized message displayed to a user
Data - localization data, see localization.
Although these properties are always present, only Message is intended for end users.
Error code
Error code is designed to help support and development teams diagnose the error.
Because it's a string instead of a number it should be descriptive enough in most circumstances. The error code can be used by an end user to determine what the error is, although it's better to use the Message field as this will contain more details about why the error occurred and possible help about how to fix the error.
Localization
Localization is not currently supported. All errors are in English.
Note
To support Localization in the future a Data array is included, containing non-translatable parts of the error message. However, at this time, you can ignore this array.
Example error
Example error payload as returned by the Consumer API
[ { "ErrorCode": "InstructionDefinition.CannotDeleteDueToPendingInstructions", "Message": "Instruction definition 1E-Explorer-TachyonCore-BiosDetails cannot be deleted because there are pending instructions based on it.", "Data": [ "1E-Explorer-TachyonCore-BiosDetails" ] } ]
Errors in Consumer API SDK
If you're using Consumer API .NET SDK, the errors are returned inside the ApiCallResponse class in the property called Errors, which is a collection. If the call was unsuccessful and the Success property is set to False, the Errors collection should contain the errors received. The Error class (contained by the Errors collection) has an additional field called ErrorType:
If ErrorType is equal to "Tachyon":
Means the error was returned by the Tachyon Consumer API and it will have the structure described above.
If ErrorType is equal to "Exception":
Means an exception was thrown inside the SDK either during the course of the HTTP call itself, or during subsequent model de-serialization. The exception's message, along with messages for its inner exceptions, will be in the Message property.
If ErrorType is equal to "Other":
Means that another type of error has occurred. This most likely means that although the HTTP call itself concluded successfully, the HTTP status code received indicated an error but the error could not be translated to the standard Error structure seen above. It might have been, for instance, an HTML page. This can happen if the address for Consumer API is incorrect and the SDK contacts an address that does not belong to Consumer API, or if the request is rejected by IIS without being processed by Consumer API at all.
Finding out more about the error
To find out more about the error, look in the Consumer API and Coordinator service log files. These log files are found on the server where the Tachyon master stack is installed, by default under %PROGRAMDATA%\1E\Tachyon