Troubleshooting
This section will provide you with hints what to do if you’re having trouble with the library. If you cannot find an answer to your question, please contact us through the Kinvey Community Support forums.
Errors
On failure, all functions return an error object. This object holds the following properties:
name
holds a generic error name. The name can be used to program against.message
contains a short, user-friendly, description of the error.debug
provides hints which might help you debug the error. This property is not always populated.
Not all errors thrown by the Kinvey API are represented in the list below. If an error is not supported it will be returned as an instance of Kinvey.Errors.KinveyError
with the name property set to the name of the error and code set to the status code of the response returned from the Kinvey API. For a detailed list of possible errors returned by the backend please take a look at REST API Troubleshooting Guide.
The possible error types returned by the library is as follows:
Error | Description |
---|---|
Kinvey.Errors.ActiveUserError | An active user already exists. |
Kinvey.Errors.APIVersionNotAvailableError | This API version is not available for your app. Please retry your request with a supported API version, |
Kinvey.Errors.APIVersionNotImplementedError | This API version is not implemented. Please retry your request with a supported API version. |
Kinvey.Errors.AppProblemError | There is a problem with this app backend that prevents execution of this operation. Please contact support@kinvey.com for assistance. |
Kinvey.Errors.BadRequestError | Unable to understand request. |
Kinvey.Errors.BLError | The Business Logic script has an error. See debug message for details. |
Kinvey.Errors.CORSDisabledError | Cross Origin Support is disabled for this application. |
Kinvey.Errors.DuplicateEndUsersError | More than one user registered with this username for this application. Please contact support@kinvey.com for assistance. |
Kinvey.Errors.FeatureUnavailableError | Requested functionality is unavailable for the API version. |
Kinvey.Errors.IncompleteRequestBodyError | The request body is either missing or incomplete. |
Kinvey.Errors.IndirectCollectionAccessDisallowedError | Please use the appropriate API to access this collection for this app backend. |
Kinvey.Errors.InsufficientCredentialsError | The credentials used to authenticate the request are not authorized to run this operation. Please retry the request with appropriate credentials. |
Kinvey.Errors.InvalidCredentialsError | Invalid credentials. Please retry the request with correct credentials. |
Kinvey.Errors.InvalidIdentifierError | One of more identifier names in the request has an invalid format. |
Kinvey.Errors.InvalidQuerySyntaxError | The query string in the request has an invalid syntax. |
Kinvey.Errors.JSONParseError | Unable to parse the JSON in the request. |
Kinvey.Errors.KinveyInternalErrorRetry | The Kinvey server encountered an unexpected error. Please retry your request. |
Kinvey.Errors.KinveyInternalErrorStop | The Kinvey server encountered an unexpected error. Please contact support@kinvey.com for assistance. |
Kinvey.Errors.KinveyError | An error has occurred. This is a general error. |
Kinvey.Errors.MissingQueryError | The request is missing a query string. |
Kinvey.Errors.MissingRequestHeaderError | The request is missing a required header. |
Kinvey.Errors.MissingRequestParameterError | A required parameter is missing from the request. |
Kinvey.Errors.MobileIdentityConnectError | An error has occurred with Mobile Identity Connect. |
Kinvey.Errors.NoActiveUserError | There is not an active user. |
Kinvey.Errors.NoNetworkConnectionError | You do not have a network connection. |
Kinvey.Errors.NoResponseError | No response was provided for the request. |
Kinvey.Errors.NotFoundError | The item was not found. |
Kinvey.Errors.ParameterValueOutOfRangeError | The value specified for one of the request parameters is out of range. |
Kinvey.Errors.PopupError | An error occurred with the popup. |
Kinvey.Errors.QueryError | An error occurred with the query. |
Kinvey.Errors.ServerError | An error occurred on the query. |
Kinvey.Errors.SyncError | An error occurred during sync. |
Kinvey.Errors.TimeoutError | The request timed out. |
Kinvey.Errors.UserAlreadyExistsError | This username is already taken. Please retry your request with a different username. |
Kinvey.Errors.WritesToCollectionDisallowedError | This collection is configured to disallow any modifications to an existing entity or creation of new entities. |
Error Handling
To check for certain errors, we recommend to check if the error
is an instanceof
of the error object listed in the Errors section.
Example: Check if an error is an ActiveUserError
Kinvey.User.login('username', 'password');
.catch(function(error) {
if (error instanceof Kinvey.Errors.ActiveUserError) {
// ...
}
});
Example: Check if an error is a NotFoundError
var store = Kinvey.DataStore.collection('collection-name');
store.findById('entity-id')
.subscribe(null, function(error) {
if (error instanceof Kinvey.Errors.NotFoundError) {
// ...
}
});
Example: Check if an error is an ActiveUserError
using the name
property
Kinvey.User.login('username', 'password');
.catch(function(error) {
if (error.name === 'ActiveUserError') {
// ...
}
});
Example: Check if an error is a NotFoundError
using the name
property
var store = Kinvey.DataStore.collection('collection-name');
store.findById('entity-id')
.subscribe(null, function(error) {
// A NotFoundError could have a different name depending on the response from
// the Kinvey API. It is recommended to use instanceof instead.
if (error.name === 'NotFoundError') {
// ...
}
});
Exceptions
If you are using promises, any exceptions thrown inside the then
handlers will be caught by the promise. What this means is that the following:
promise
.then(function() {
throw new Error('I am just an error.');
});
Will not cause the exception to be visible in the log panel of your browser or IDE. This can lead to confusion as it seems that everything went fine, while in reality, the exception is thrown but not reported. To correctly deal with exceptions in promises, consider the approach below.
promise
.then(funtion() {
throw new Error('I am just an error.');
})
.catch(function(error) {
// Check whether the error is an exception.
if (error instanceof Error) {
// error holds the Error thrown in the then handler above.
// error.message === 'I am just an error.';
}
});
The error.message
and error.stack
properties will provide insight in what went wrong, and where.
Debugging
The library uses loglevel to log information. The default log level is Kinvey.Log.levels.SILENT
. You can change the log level as show below.
Kinvey.Log.setLevel(Kinvey.Log.levels.DEBUG);
From then on, the flow of every call you make will be printed out using loglevel. You might be able to identify the error by inspecting these messages. When contacting Kinvey, sending this log along will be of great help.
Tools
Mac users may wish to use WireShark or Charles.
Windows developers can use Fiddler which is the preferred tool at Kinvey.
There are a few open source and proprietary Java tools listed at Ask Ubuntu and one can always use Firebug through Firefox, or the Developer Tools through Chrome.