Last updated

Errors

Deprecated

The Storm API client for .net has been tag:ed end of life and will cease to be updated and supported in roll out tests in an unspecified later date.

All Storm’s API’s moves to open API standards and swagger endpoints, and the old clients with dependencies to 3rd party technologies or tools will stop being supported. No specific date is set yet.

There are two kinds of exceptions that the API will throw. Basically, they are of the same type, FaultException, but with different messages: “Bad Request” (400) or “Internal Server Error” (500).

API Client with Non WCF REST endpoint

Bad Requests contain messages that can be shown to the end users, while Internal Server Error does not. These exceptions are logged in the back-end and can be viewed from the API Reference.

When catching faults from the API, use a catch like this:

try
{
    // make call to the API.
}
catch (FaultException<ErrorMessage> ex)
{
    if(ex.Message == "Bad Request")
    {
        // Display message to end user.
    }
    else
    {
        // Display some generic fault message
    }
}

When processing Bad Requests, use the ex.Detail to get the information sent by the API. ex.Detail is of type ErrorMessage and its Record-property will contain a Messages list of faults when returned from the API. The list is a Key-Value dictionary, where the Key in the list is a constant representing the text (Value) and can be hard coded against. The Value will be the Storm Commerce fault text.

In order to handle different faults in a custom way, do as following when dealing with Bad Requests:

var message = ex.Detail.Message;
var messages = ex.Detail.Messages; // To get the dictionary
if (messages.ContainsKey("QuotationMissing")
{
    message += " " + messages["QuotationMissing"];
    // Or append a costom message for Quotation missing
}
// Check other Names if required.
// Display message to user.

REST-ish

When used with a WCF REST endpoint, a WebFaultException will be thrown. Otherwise all above applies.

Fault names

Here are links to all fault names and what value they return for all languages that are available.