summaryrefslogtreecommitdiff
path: root/src/mhd/mhd_responses.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mhd/mhd_responses.c')
-rw-r--r--src/mhd/mhd_responses.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mhd/mhd_responses.c b/src/mhd/mhd_responses.c
index 5ed82cd2..9e6986a3 100644
--- a/src/mhd/mhd_responses.c
+++ b/src/mhd/mhd_responses.c
@@ -443,6 +443,37 @@ TALER_MHD_reply_with_error (struct MHD_Connection *connection,
/**
+ * Send a response indicating an error. The HTTP status code is
+ * to be derived from the @a ec.
+ *
+ * @param connection the MHD connection to use
+ * @param ec error code uniquely identifying the error
+ * @param detail additional optional detail about the error
+ * @return a MHD result code
+ */
+MHD_RESULT
+TALER_MHD_reply_with_ec (struct MHD_Connection *connection,
+ enum TALER_ErrorCode ec,
+ const char *detail)
+{
+ unsigned int hc = TALER_ErrorCode_get_http_status (ec);
+
+ if ( (0 == hc) ||
+ (UINT_MAX == hc) )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Invalid Taler error code %d provided for response!\n",
+ (int) ec);
+ hc = MHD_HTTP_INTERNAL_SERVER_ERROR;
+ }
+ return TALER_MHD_reply_with_error (connection,
+ hc,
+ ec,
+ detail);
+}
+
+
+/**
* Send a response indicating that the request was too big.
*
* @param connection the MHD connection to use