Items API Initialization
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 an invalid Item reference will throw:
{
"code": 20013,
"msg": "Requested items could not be retrieved. Items references: missing_item_reference"
}
*/
},
// ...
};
var itemsApp = window.LearnosityItems.init(
initializationOptions,
callbacks
);
Arguments
-
errorEvent object
An object containing information on the error or error event that was thrown by the API. See Items API Troubleshooting for a full list of error codes.
-
code number
The Learnosity error code returned by the API.
-
msg string
The name and description of the error event.
-
detail string
Additional information for the error that was thrown. May not always be returned depending on the error.
-
Return value
None (undefined
).