Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
[doc] Add details on error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
errordeveloper committed May 28, 2013
1 parent 00725d1 commit 0cbfa0e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,32 @@ datastreams[2].setString("Pretty comfy temperature"); // Push a String datapoi
datastreams[3].setBuffer("But quite dry"); // Push a char buffer datapoint
```

##Error codes

This library uses [_amcewen/HttpClient_](https://github.com/amcewen/HttpClient/blob/master/HttpClient.h) which has following error codes:

* `HTTP_SUCCESS = 0` - no error
* `HTTP_ERROR_CONNECTION_FAILED = -1` - connection to _api.xively.com_ has failed
* `HTTP_ERROR_API = -2` - a method of _HttpClient_ class was called incorrectly
* `HTTP_ERROR_TIMED_OUT = -3` - connection with _api.xively.com_ has timed-out
* `HTTP_ERROR_INVALID_RESPONSE = -4` - invalid or unexpected response from the server

Apart from the above, the library will convert any _non-2xx_ status code to a nagative value like so:
```c
ret = http.responseStatusCode();
if ((ret < 200) || (ret > 299))
{

if (ret > 0)
{
ret = ret * -1;
}
}
```

Therefore:
* if we got a _2xx_, we will return that as is
* if we got a negative value (e.g. `HTTP_ERROR_CONNECTION_FAILED`, `HTTP_ERROR_TIMED_OUT` or other), we will return that as is
* any _non-2xx_ status code is returned multiplied by _-1_, i.e. a _403 (Authentication error)_ will be returned as _-403_

[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/fa828feced5044961a2e1b6481ed83a9 "githalytics.com")](http://githalytics.com/xively/xively-arduino)

0 comments on commit 0cbfa0e

Please sign in to comment.