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.
  • code set to the status code of a network response. Default value is -1.
  • kinveyRequestId set to the X-Kinvey-Request-Id header value for Kinvey API requests. Default value is undefined.

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.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 dictionary of error codes returned by the library is as follows:

ErrorDescription
$kinvey.ActiveUserErrorAn active user already exists.
$kinvey.APIVersionNotAvailableErrorThis API version is not available for your app. Please retry your request with a supported API version,
$kinvey.APIVersionNotImplementedErrorThis API version is not implemented. Please retry your request with a supported API version.
$kinvey.AppProblemErrorThere is a problem with this app backend that prevents execution of this operation. Please contact support@kinvey.com for assistance.
$kinvey.BadRequestErrorUnable to understand request.
$kinvey.BLErrorThe Business Logic script has an error. See debug message for details.
$kinvey.CORSDisabledErrorCross Origin Support is disabled for this application.
$kinvey.DuplicateEndUsersErrorMore than one user registered with this username for this application. Please contact support@kinvey.com for assistance.
$kinvey.FeatureUnavailableErrorRequested functionality is unavailable for the API version.
$kinvey.IncompleteRequestBodyErrorThe request body is either missing or incomplete.
$kinvey.IndirectCollectionAccessDisallowedErrorPlease use the appropriate API to access this collection for this app backend.
$kinvey.InsufficientCredentialsErrorThe credentials used to authenticate the request are not authorized to run this operation. Please retry the request with appropriate credentials.
$kinvey.InvalidCredentialsErrorInvalid credentials. Please retry the request with correct credentials.
$kinvey.InvalidIdentifierErrorOne of more identifier names in the request has an invalid format.
$kinvey.InvalidQuerySyntaxErrorThe query string in the request has an invalid syntax.
$kinvey.JSONParseErrorUnable to parse the JSON in the request.
$kinvey.KinveyInternalErrorRetryThe Kinvey server encountered an unexpected error. Please retry your request.
$kinvey.KinveyInternalErrorStopThe Kinvey server encountered an unexpected error. Please contact support@kinvey.com for assistance.
$kinvey.KinveyErrorAn error has occurred. This is a general error.
$kinvey.MissingQueryErrorThe request is missing a query string.
$kinvey.MissingRequestHeaderErrorThe request is missing a required header.
$kinvey.MissingRequestParameterErrorA required parameter is missing from the request.
$kinvey.MobileIdentityConnectErrorAn error has occurred with Mobile Identity Connect.
$kinvey.NoActiveUserErrorThere is not an active user.
$kinvey.NoNetworkConnectionErrorYou do not have a network connection.
$kinvey.NoResponseErrorNo response was provided for the request.
$kinvey.NotFoundErrorThe item was not found.
$kinvey.ParameterValueOutOfRangeErrorThe value specified for one of the request parameters is out of range.
$kinvey.PopupErrorAn error occurred with the popup.
$kinvey.QueryErrorAn error occurred with the query.
$kinvey.ServerErrorAn error occurred on the query.
$kinvey.SyncErrorAn error occurred during sync.
$kinvey.TimeoutErrorThe request timed out.
$kinvey.UserAlreadyExistsErrorThis username is already taken. Please retry your request with a different username.
$kinvey.WritesToCollectionDisallowedErrorThis 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.name === 'ActiveUserError') {
      // ...
    }
  });

Example: Check if an error is a NotFoundError

var store = $kinvey.DataStore.collection('collection-name');
var stream = store.findById('entity-id');
stream.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') {
    // ...
  }
});

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.