Mendix Client 5 API Documentation


mendix.lib.Error

Some API functions that take a callback, also take an error callback for handling error situations. The error callback is passed an instance of a mendix.lib.Error (or decendent) object.

Currently, the following specializations of mendix.lib.Error are defined:

mendix.lib.ConnectionError
Something went wrong with the connection to the runtime.
mendix.lib.ValidationError
A runtime validation error occured.

To tell the difference between different Error types, you can use instanceof:

mx.data.get({
    guid: "12345",
    callback: function(obj) {
        console.log("Received an object: " + obj.getGuid());
    },
    error: function(err) {
        if (err instanceof mendix.lib.ConnectionError) {
            console.log("Connection error: " + err.message);
        } else if (err instanceof mendix.lib.ValidationError) {
            console.log("Validation error: " + err.message);
        } else {
            console.log("Generic error: " + err.message);
        }
    }

Properties

message

The error message.