API XML Error

From FreeDESK
(Difference between revisions)
Jump to: navigation, search
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="php5">
 +
// 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>

Revision as of 18:45, 21 August 2012

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:

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, asm, asp, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, oobas, oracle11, oracle8, oxygene, oz, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, python, q, qbasic, rails, rebol, reg, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, sql, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, uscript, vala, vb, vbnet, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


// 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