aboutsummaryrefslogtreecommitdiff
path: root/gnu-taler-error-codes
diff options
context:
space:
mode:
Diffstat (limited to 'gnu-taler-error-codes')
-rw-r--r--gnu-taler-error-codes/c.footer18
-rw-r--r--gnu-taler-error-codes/h.footer14
2 files changed, 30 insertions, 2 deletions
diff --git a/gnu-taler-error-codes/c.footer b/gnu-taler-error-codes/c.footer
index 118aa08..163901f 100644
--- a/gnu-taler-error-codes/c.footer
+++ b/gnu-taler-error-codes/c.footer
@@ -27,7 +27,7 @@ TALER_ErrorCode_get_hint (enum TALER_ErrorCode ec)
27} 27}
28 28
29 29
30const unsigned int 30unsigned int
31TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec) 31TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec)
32{ 32{
33 unsigned int lower = 0; 33 unsigned int lower = 0;
@@ -51,3 +51,19 @@ TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec)
51 } 51 }
52 return UINT_MAX; 52 return UINT_MAX;
53} 53}
54
55
56unsigned int
57TALER_ErrorCode_get_http_status_safe (enum TALER_ErrorCode ec)
58{
59 unsigned int hc;
60
61 hc = TALER_ErrorCode_get_http_status (ec);
62 if ( (0 == hc) ||
63 (UINT_MAX == hc) )
64 {
65 GNUNET_break (0);
66 return MHD_HTTP_INTERNAL_SERVER_ERROR;
67 }
68 return hc;
69}
diff --git a/gnu-taler-error-codes/h.footer b/gnu-taler-error-codes/h.footer
index 67d90c8..714e7f4 100644
--- a/gnu-taler-error-codes/h.footer
+++ b/gnu-taler-error-codes/h.footer
@@ -19,10 +19,22 @@ TALER_ErrorCode_get_hint (enum TALER_ErrorCode ec);
19 * @param ec the error code. 19 * @param ec the error code.
20 * @return the HTTP status code for the given @a ec, UINT_MAX if not found 20 * @return the HTTP status code for the given @a ec, UINT_MAX if not found
21 */ 21 */
22const unsigned int 22unsigned int
23TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec); 23TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec);
24 24
25 25
26/**
27 * Return HTTP status for a given error code that is guaranteed
28 * to work (no corner cases).
29 *
30 * @param ec the error code.
31 * @return the HTTP status code for the given @a ec, 500 if
32 * the @a ec is not found or is a client-side code
33 */
34unsigned int
35TALER_ErrorCode_get_http_status_safe (enum TALER_ErrorCode ec);
36
37
26#if 0 /* keep Emacsens' auto-indent happy */ 38#if 0 /* keep Emacsens' auto-indent happy */
27{ 39{
28#endif 40#endif