Skip to content
Adrien Castex edited this page Jun 19, 2017 · 2 revisions

The server manage three kinds of errors : Basic errors (of class Error), errors of a manager not found (of class ManagerNotFound) and HTTP errors (of class HTTPError).

Common errors

The module provides a list of common errors. When a common error is occurring, it uses the reference stored in the Errors constant. This way, you can check in a common error occurred with the === operator :

resource.action((error) => {
    if(error === Errors.ResourceNotFound)
    {
        // The resource is not found
    }
    else if(error)
    {
        // Another error occured
    }

    // [...]
})

Here is the list of the common errors :

Name Text
BadAuthentication Bad authentication.
AuenticationPropertyMissing Properties are missing.
WrongHeaderFormat Wrong header format.
MissingAuthorisationHeader Missing Authorization header.
UnrecognizedResource Unrecognized resource.
ParentPropertiesMissing The parent resource must have some special properties.
InvalidOperation Invalid operation.
ResourceAlreadyExists The resource already exists.
ResourceNotFound Can't find the resource.
CannotLockResource Can't lock the resource.
PropertyNotFound No property with such name.
AlreadyAuthenticated Already authenticated.
UserNotFound User not found.
XMLNotFound Can't find the XML element.
ExpectedAFileResourceType Expected a file resource type.
NoMimeTypeForAFolder Cannot get the mime type of a folder type resource.
NoSizeForAFolder Cannot get the size of a folder type resource.
IllegalArguments Illegal arguments.
MustIgnore There was an error but it must not stop the processing.

HTTP errors

A HTTP error is materialized by the HTTPError class. It has an error code (usually the status code to response) and it can have an inner error which produced the HTTP error. The semantic of the HTTPError class is the following : An error occurred (inheritedError), in this special case, the server must response with the appropriate status code (HTTPCode).

Implementation

class HTTPError extends Error
{
    constructor(public HTTPCode : number, public inheritedError ?: Error)
    {
        super('Error ' + HTTPCode)
    }
}

Manager not found error

The 'Manager not found error' is materialized by the ManagerNotFound class. It is used during unserialization to mark the difference between an execution error and a FSManager not found.

Implementation

class ManagerNotFound extends Error
{
    constructor(public managerUID : string)
    {
        super('Cannot find the manager : ' + managerUID);
    }
}
Clone this wiki locally