Skip to content

Commit 0cbfa0e

Browse files
author
Ilya Dmitrichenko
committed
[doc] Add details on error codes
1 parent 00725d1 commit 0cbfa0e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,32 @@ datastreams[2].setString("Pretty comfy temperature"); // Push a String datapoi
141141
datastreams[3].setBuffer("But quite dry"); // Push a char buffer datapoint
142142
```
143143

144+
##Error codes
145+
146+
This library uses [_amcewen/HttpClient_](https://github.com/amcewen/HttpClient/blob/master/HttpClient.h) which has following error codes:
147+
148+
* `HTTP_SUCCESS = 0` - no error
149+
* `HTTP_ERROR_CONNECTION_FAILED = -1` - connection to _api.xively.com_ has failed
150+
* `HTTP_ERROR_API = -2` - a method of _HttpClient_ class was called incorrectly
151+
* `HTTP_ERROR_TIMED_OUT = -3` - connection with _api.xively.com_ has timed-out
152+
* `HTTP_ERROR_INVALID_RESPONSE = -4` - invalid or unexpected response from the server
153+
154+
Apart from the above, the library will convert any _non-2xx_ status code to a nagative value like so:
155+
```c
156+
ret = http.responseStatusCode();
157+
if ((ret < 200) || (ret > 299))
158+
{
159+
160+
if (ret > 0)
161+
{
162+
ret = ret * -1;
163+
}
164+
}
165+
```
166+
167+
Therefore:
168+
* if we got a _2xx_, we will return that as is
169+
* if we got a negative value (e.g. `HTTP_ERROR_CONNECTION_FAILED`, `HTTP_ERROR_TIMED_OUT` or other), we will return that as is
170+
* any _non-2xx_ status code is returned multiplied by _-1_, i.e. a _403 (Authentication error)_ will be returned as _-403_
171+
144172
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/fa828feced5044961a2e1b6481ed83a9 "githalytics.com")](http://githalytics.com/xively/xively-arduino)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy