Error Handling

We’re handling errors on many levels. What the front-end integrators need to know is that, if an error occurs at some point (Database, HTTP request, etc), the corresponding payload is sent back to the user:

{
    "errors": [
        {
            "title": "Database Error",
            "detail": "An error has occurred. Please contact your administrator"
        }
    ]
}

This error payload format is inspired by JSON API

Important

Along with this payload, the response status code may be a 4xx or a 5xx depending on the error raised.

Display errors on the front-end side

You may browse the selectize.js file, that shows an example on how to handle errors and use them in your user interface:

function errorCallback(resp) {
    $('.error').remove();
    errors = resp.responseJSON.errors;
    status = resp.status;
    console.debug(status);
    console.debug(errors);
    content = '<div class="error">Error status code: ' + status;
    content += '<ul>';
    for (var i = 0; i < errors.length; i++) {
        content += '<li>' + errors[i].title + ': ' + errors[i].detail + '</li>';
    }
    content += '<ul></div>';
    $('#search-form').after(content);
}