API XML Error

From FreeDESK
Jump to: navigation, search

A FreeDESK XML error will contain an error code and textual description.

Contents

Example

<error>
 <code>XXXX</code>
 <text>Textual Error Description</text>
</error>

Error Codes

The following is a list of in-built error codes based upon the ErrorCode class. You may use your own error codes which can either be captured by your own receipt handling code or will be detected client-side with the DESK.isError(xml) call.

101 ErrorCode::FailedLogin

Login has failed

102 ErrorCode::SessionExpired

Attempt to validate client SID has failed as it has expired (or has been deleted, or is illegal)

201 ErrorCode::UnknownMode

The API has been called with an unknown or unregistered mode

300 ErrorCode::EntityError

An error has occurred when fetching/searching/writing an entity. The system logs will provide more information.

403 ErrorCode::Forbidden

Current user context does not have access to the mode or resource requested

404 ErrorCode::ResourceNotFound

A resource was asked for that does not exist or has not been registered

406 ErrorCode::UnknownRequest

A request has been received of a type which is unknown or unregistered

700 ErrorCode::OperationFailed

Generic failure, the operation requested has failed. Used to indicate a general call failure of an API call for some unknown reason.

Creating Custom Errors

To create a custom error use the FreeDESK_Error class as follows:

// Our error information
$code = 999;
$text = "An Error";
// Create a FreeDESK_Error
$myError = new FreeDESK_Error($code, $text);
// Output the XML
echo $myError->XML();
// n.b. this will output XML without header
// $myError->XML(true) will include an XML header
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox