Initialization Option Author API

errorListener

This function is called when one of the preset Learnosity API errors are thrown.

You would want to define this callback so that you can display your own error message or track the error in your own error reporting systems, for example.

Examples

var callbacks = {
    errorListener: function (errorEvent) {
        console.log('The callback that is executed when a Learnosity API error occurs.');

        console.log(errorEvent);
        /* For example, providing invalid security details will throw:
            {
                "code": 41000,
                "msg": "Missing security parameters"
            }
        */

    },
    // ...
};

var authorApp = window.LearnosityAuthor.init(
    initializationOptions,
    callbacks
);

Values

Type function

Callback arguments

The callback receives the following arguments when it is executed.

  • error object

    Object containing error details.

    • code number

      The Learnosity error code returned by the API.

    • message string

      Message containing information about the error.

    • status boolean

      The error status which will always be false, indicating a failed operation.

    • timestamp number

      Returns time (in milliseconds) when the error occurred.

Related articles

Was this article helpful?