API XML Error

From FreeDESK
(Difference between revisions)
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 10: Line 10:
  
 
== Error Codes ==
 
== 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:
 +
<source lang="php">
 +
// 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
 +
</source>

Latest revision as of 18:46, 21 August 2012

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

Contents

[edit] Example

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

[edit] 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.

[edit] 101 ErrorCode::FailedLogin

Login has failed

[edit] 102 ErrorCode::SessionExpired

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

[edit] 201 ErrorCode::UnknownMode

The API has been called with an unknown or unregistered mode

[edit] 300 ErrorCode::EntityError

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

[edit] 403 ErrorCode::Forbidden

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

[edit] 404 ErrorCode::ResourceNotFound

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

[edit] 406 ErrorCode::UnknownRequest

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

[edit] 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.

[edit] 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