GNUnet 0.22.2
gnunet_error_codes.h File Reference
#include <limits.h>
Include dependency graph for gnunet_error_codes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  GNUNET_ErrorCode {
  GNUNET_EC_NONE = 0 , GNUNET_EC_UNKNOWN = 1 , GNUNET_EC_SERVICE_COMMUNICATION_FAILED = 101 , GNUNET_EC_IDENTITY_NOT_FOUND = 200 ,
  GNUNET_EC_IDENTITY_NAME_CONFLICT = 201 , GNUNET_EC_IDENTITY_INVALID = 202 , GNUNET_EC_NAMESTORE_UNKNOWN = 5000 , GNUNET_EC_NAMESTORE_ITERATION_FAILED = 5001 ,
  GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND = 5002 , GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND = 5003 , GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED = 5004 , GNUNET_EC_NAMESTORE_ZONE_EMPTY = 5005 ,
  GNUNET_EC_NAMESTORE_LOOKUP_ERROR = 5006 , GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN = 5007 , GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID = 5008 , GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN = 5009 ,
  GNUNET_EC_NAMESTORE_NO_RESULTS = 5010 , GNUNET_EC_NAMESTORE_RECORD_EXISTS = 5011 , GNUNET_EC_NAMESTORE_RECORD_TOO_BIG = 5012 , GNUNET_EC_NAMESTORE_BACKEND_FAILED = 5013 ,
  GNUNET_EC_NAMESTORE_STORE_FAILED = 5014 , GNUNET_EC_NAMESTORE_LABEL_INVALID = 5015
}
 Taler error codes. More...
 

Functions

const char * GNUNET_ErrorCode_get_hint (enum GNUNET_ErrorCode ec)
 Returns a hint for a given error code. More...
 
unsigned int GNUNET_ErrorCode_get_http_status (enum GNUNET_ErrorCode ec)
 Return HTTP status for a given error code. More...
 
unsigned int GNUNET_ErrorCode_get_http_status_safe (enum GNUNET_ErrorCode ec)
 Return HTTP status for a given error code that is guaranteed to work (no corner cases). More...
 

Enumeration Type Documentation

◆ GNUNET_ErrorCode

Taler error codes.

Enumerator
GNUNET_EC_NONE 

No error (success).

Returned with an HTTP status code of MHD_HTTP_UNINITIALIZED (0).

GNUNET_EC_UNKNOWN 

Unknown and unspecified error.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_SERVICE_COMMUNICATION_FAILED 

Communication with service failed.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_IDENTITY_NOT_FOUND 

Ego not found.

Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).

GNUNET_EC_IDENTITY_NAME_CONFLICT 

Identifier already in use for another ego.

Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).

GNUNET_EC_IDENTITY_INVALID 

The given ego is invalid or malformed.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_UNKNOWN 

Unknown namestore error.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_ITERATION_FAILED 

Zone iteration failed.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND 

Zone not found.

Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).

GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND 

Record not found.

Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).

GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED 

Zone iteration failed.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_ZONE_EMPTY 

Zone does not contain any records.

Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).

GNUNET_EC_NAMESTORE_LOOKUP_ERROR 

Failed to lookup record.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN 

No records given.

Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).

GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID 

Record data invalid.

Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).

GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN 

No label given.

Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).

GNUNET_EC_NAMESTORE_NO_RESULTS 

No results given.

Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404).

GNUNET_EC_NAMESTORE_RECORD_EXISTS 

Record already exists.

Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409).

GNUNET_EC_NAMESTORE_RECORD_TOO_BIG 

Record size exceeds maximum limit.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_BACKEND_FAILED 

There was an error in the database backend.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_STORE_FAILED 

Failed to store the given records.

Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500).

GNUNET_EC_NAMESTORE_LABEL_INVALID 

Label invalid or malformed.

Returned with an HTTP status code of #MHD_HTTP_BAD_REQUEST (400).

Definition at line 42 of file gnunet_error_codes.h.

43{
44
45
51
52
58
59
65
66
72
73
79
80
86
87
93
94
100
101
107
108
114
115
121
122
128
129
135
136
142
143
149
150
156
157
163
164
170
171
177
178
184
185
191
192
198
199
200};
@ GNUNET_EC_NAMESTORE_NO_RESULTS
No results given.
@ GNUNET_EC_NAMESTORE_RECORD_DELETE_FAILED
Zone iteration failed.
@ GNUNET_EC_NAMESTORE_LABEL_INVALID
Label invalid or malformed.
@ GNUNET_EC_NAMESTORE_LOOKUP_ERROR
Failed to lookup record.
@ GNUNET_EC_IDENTITY_INVALID
The given ego is invalid or malformed.
@ GNUNET_EC_NAMESTORE_BACKEND_FAILED
There was an error in the database backend.
@ GNUNET_EC_NAMESTORE_ITERATION_FAILED
Zone iteration failed.
@ GNUNET_EC_NAMESTORE_ZONE_EMPTY
Zone does not contain any records.
@ GNUNET_EC_NAMESTORE_RECORD_TOO_BIG
Record size exceeds maximum limit.
@ GNUNET_EC_SERVICE_COMMUNICATION_FAILED
Communication with service failed.
@ GNUNET_EC_NAMESTORE_STORE_FAILED
Failed to store the given records.
@ GNUNET_EC_NAMESTORE_NO_LABEL_GIVEN
No label given.
@ GNUNET_EC_NAMESTORE_RECORD_DATA_INVALID
Record data invalid.
@ GNUNET_EC_NAMESTORE_NO_RECORDS_GIVEN
No records given.
@ GNUNET_EC_UNKNOWN
Unknown and unspecified error.
@ GNUNET_EC_NAMESTORE_ZONE_NOT_FOUND
Zone not found.
@ GNUNET_EC_NONE
No error (success).
@ GNUNET_EC_IDENTITY_NOT_FOUND
Ego not found.
@ GNUNET_EC_IDENTITY_NAME_CONFLICT
Identifier already in use for another ego.
@ GNUNET_EC_NAMESTORE_RECORD_EXISTS
Record already exists.
@ GNUNET_EC_NAMESTORE_UNKNOWN
Unknown namestore error.
@ GNUNET_EC_NAMESTORE_RECORD_NOT_FOUND
Record not found.

Function Documentation

◆ GNUNET_ErrorCode_get_hint()

const char * GNUNET_ErrorCode_get_hint ( enum GNUNET_ErrorCode  ec)

Returns a hint for a given error code.

Parameters
ecthe error code.
Returns
the hint if it could be found, otherwise "<no hint found>"

Definition at line 201 of file gnunet_error_codes.c.

202{
203 unsigned int lower = 0;
204 unsigned int upper = code_hint_pairs_length - 1;
205 unsigned int mid = upper / 2;
206 while (lower <= upper)
207 {
208 mid = (upper + lower) / 2;
209 if (code_hint_pairs[mid].ec < ec)
210 {
211 lower = mid + 1;
212 }
213 else if (code_hint_pairs[mid].ec > ec)
214 {
215 upper = mid - 1;
216 }
217 else
218 {
219 return code_hint_pairs[mid].hint;
220 }
221 }
222 return "<no hint found>";
223}
static const unsigned int code_hint_pairs_length
The length of code_hint_pairs.
static const struct ErrorCodeAndHint code_hint_pairs[]
The list of all error codes with their hints.
const char * hint
The hint.

References code_hint_pairs, code_hint_pairs_length, ErrorCodeAndHint::ec, and ErrorCodeAndHint::hint.

Referenced by add_continuation(), attr_store_cont(), create_did_ego_create_cb(), create_finished(), cred_store_cont(), del_attr_finished(), del_continuation(), delete_finished(), DID_create_did_store_cb(), do_error(), handle_generic_response(), handle_zone_to_name_response(), marked_deleted(), move_attr_finished(), origin_create_cb(), remove_did_document_namestore_cb(), remove_ticket_cont(), replace_cont(), send_result_code(), and store_completed_cb().

Here is the caller graph for this function:

◆ GNUNET_ErrorCode_get_http_status()

unsigned int GNUNET_ErrorCode_get_http_status ( enum GNUNET_ErrorCode  ec)

Return HTTP status for a given error code.

Parameters
ecthe error code.
Returns
the HTTP status code for the given ec, UINT_MAX if not found

Definition at line 227 of file gnunet_error_codes.c.

228{
229 unsigned int lower = 0;
230 unsigned int upper = code_hint_pairs_length - 1;
231 unsigned int mid = upper / 2;
232 while (lower <= upper)
233 {
234 mid = (upper + lower) / 2;
235 if (code_hint_pairs[mid].ec < ec)
236 {
237 lower = mid + 1;
238 }
239 else if (code_hint_pairs[mid].ec > ec)
240 {
241 upper = mid - 1;
242 }
243 else
244 {
245 return code_hint_pairs[mid].http_code;
246 }
247 }
248 return UINT_MAX;
249}
unsigned int http_code
The HTTP status code.

References code_hint_pairs, code_hint_pairs_length, ErrorCodeAndHint::ec, and ErrorCodeAndHint::http_code.

Referenced by do_error(), and GNUNET_ErrorCode_get_http_status_safe().

Here is the caller graph for this function:

◆ GNUNET_ErrorCode_get_http_status_safe()

unsigned int GNUNET_ErrorCode_get_http_status_safe ( enum GNUNET_ErrorCode  ec)

Return HTTP status for a given error code that is guaranteed to work (no corner cases).

Parameters
ecthe error code.
Returns
the HTTP status code for the given ec, 500 if the ec is not found or is a client-side code

Definition at line 253 of file gnunet_error_codes.c.

254{
255 unsigned int hc;
256
258 if ( (0 == hc) ||
259 (UINT_MAX == hc) )
260 return MHD_HTTP_INTERNAL_SERVER_ERROR;
261 return hc;
262}
unsigned int GNUNET_ErrorCode_get_http_status(enum GNUNET_ErrorCode ec)
Return HTTP status for a given error code.

References ErrorCodeAndHint::ec, and GNUNET_ErrorCode_get_http_status().

Here is the call graph for this function: