summaryrefslogtreecommitdiff
path: root/src/mint/taler-mint-httpd_deposit.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-08 09:40:13 +0200
committerChristian Grothoff <christian@grothoff.org>2015-07-08 09:40:13 +0200
commitea5c1233f13ad3128207b6b84401d8638dbc43e5 (patch)
tree4ee2fc37580df6079af9acb339de804ee38846d7 /src/mint/taler-mint-httpd_deposit.c
parent296e27b92ab0367f414dc0e98b185531c8df06f3 (diff)
downloadexchange-ea5c1233f13ad3128207b6b84401d8638dbc43e5.tar.gz
exchange-ea5c1233f13ad3128207b6b84401d8638dbc43e5.tar.bz2
exchange-ea5c1233f13ad3128207b6b84401d8638dbc43e5.zip
nicer error reporting
Diffstat (limited to 'src/mint/taler-mint-httpd_deposit.c')
-rw-r--r--src/mint/taler-mint-httpd_deposit.c38
1 files changed, 11 insertions, 27 deletions
diff --git a/src/mint/taler-mint-httpd_deposit.c b/src/mint/taler-mint-httpd_deposit.c
index c1495c817..7d9ace00d 100644
--- a/src/mint/taler-mint-httpd_deposit.c
+++ b/src/mint/taler-mint-httpd_deposit.c
@@ -234,7 +234,11 @@ TMH_DEPOSIT_handler_deposit (struct TMH_RequestHandler *rh,
json_t *wire;
int res;
struct TALER_Amount amount;
- json_t *f;
+ struct TMH_PARSE_FieldSpecification spec[] = {
+ TMH_PARSE_member_object ("wire", &wire),
+ TMH_PARSE_member_amount ("f", &amount),
+ TMH_PARSE_MEMBER_END
+ };
res = TMH_PARSE_post_json (connection,
connection_cls,
@@ -245,39 +249,19 @@ TMH_DEPOSIT_handler_deposit (struct TMH_RequestHandler *rh,
return MHD_NO;
if ( (GNUNET_NO == res) || (NULL == json) )
return MHD_YES;
- if (-1 == json_unpack (json,
- "{s:o, s:o}",
- "wire", &wire,
- "f", &f))
- {
- GNUNET_break_op (0);
- json_decref (json);
- return TMH_RESPONSE_reply_json_pack (connection,
- MHD_HTTP_BAD_REQUEST,
- "{s:s}",
- "error", "Bad format");
- }
- res = TMH_PARSE_amount_json (connection,
- f,
- &amount);
- json_decref (f);
- if (GNUNET_SYSERR == res)
- {
- json_decref (wire);
- json_decref (json);
- return MHD_NO;
- }
- if (GNUNET_NO == res)
+ res = TMH_PARSE_json_data (connection,
+ json,
+ spec);
+ if (GNUNET_OK != res)
{
- json_decref (wire);
json_decref (json);
- return MHD_YES;
+ return (GNUNET_NO == res) ? MHD_YES : MHD_NO;
}
res = parse_and_handle_deposit_request (connection,
json,
&amount,
wire);
- json_decref (wire);
+ TMH_PARSE_release_data (spec);
json_decref (json);
return res;
}