aboutsummaryrefslogtreecommitdiff
path: root/src/templating
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-05-06 20:55:40 +0200
committerChristian Grothoff <christian@grothoff.org>2023-05-06 20:55:40 +0200
commit404b2b78f187e3da2fedee5748b9bfcdfa4a105c (patch)
treef774b8ca0ea11d8886c7ff02f024c9588bbeef74 /src/templating
parent1f9427e1d9672b93577aea4c9d5a63575ee0b525 (diff)
downloadexchange-404b2b78f187e3da2fedee5748b9bfcdfa4a105c.tar.xz
add convenience function TALER_TEMPLATING_reply_error
Diffstat (limited to 'src/templating')
-rw-r--r--src/templating/templating_api.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/templating/templating_api.c b/src/templating/templating_api.c
index 324e199eb..dba042e5d 100644
--- a/src/templating/templating_api.c
+++ b/src/templating/templating_api.c
@@ -428,6 +428,45 @@ load_template (void *cls,
}
+MHD_RESULT
+TALER_TEMPLATING_reply_error (struct MHD_Connection *connection,
+ const char *template_basename,
+ unsigned int http_status,
+ enum TALER_ErrorCode ec,
+ const char *detail)
+{
+ json_t *data;
+ enum GNUNET_GenericReturnValue ret;
+
+ data = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_uint64 ("ec",
+ ec),
+ GNUNET_JSON_pack_string ("hint",
+ TALER_ErrorCode_get_hint (ec)),
+ GNUNET_JSON_pack_string ("detail",
+ detail)
+ );
+ ret = TALER_TEMPLATING_reply (connection,
+ http_status,
+ template_basename,
+ NULL,
+ NULL,
+ data);
+ json_decref (data);
+ switch (ret)
+ {
+ case GNUNET_OK:
+ return MHD_YES;
+ case GNUNET_NO:
+ return MHD_YES;
+ case GNUNET_SYSERR:
+ return MHD_NO;
+ }
+ GNUNET_assert (0);
+ return MHD_NO;
+}
+
+
enum GNUNET_GenericReturnValue
TALER_TEMPLATING_init (const char *subsystem)
{