summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
}
-const unsigned int
+unsigned int
TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec)
{
unsigned int lower = 0;
@@ -51,3 +51,19 @@ TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec)
}
return UINT_MAX;
}
+
+
+unsigned int
+TALER_ErrorCode_get_http_status_safe (enum TALER_ErrorCode ec)
+{
+ unsigned int hc;
+
+ hc = TALER_ErrorCode_get_http_status (ec);
+ if ( (0 == hc) ||
+ (UINT_MAX == hc) )
+ {
+ GNUNET_break (0);
+ return MHD_HTTP_INTERNAL_SERVER_ERROR;
+ }
+ return hc;
+}
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);
* @param ec the error code.
* @return the HTTP status code for the given @a ec, UINT_MAX if not found
*/
-const unsigned int
+unsigned int
TALER_ErrorCode_get_http_status (enum TALER_ErrorCode ec);
+/**
+ * Return HTTP status for a given error code that is guaranteed
+ * to work (no corner cases).
+ *
+ * @param ec the error code.
+ * @return the HTTP status code for the given @a ec, 500 if
+ * the @a ec is not found or is a client-side code
+ */
+unsigned int
+TALER_ErrorCode_get_http_status_safe (enum TALER_ErrorCode ec);
+
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif