aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
m---------contrib/gana0
-rw-r--r--src/auditor/taler-auditor-httpd_deposit-confirmation.c12
-rw-r--r--src/auditor/taler-auditor-httpd_exchanges.c4
-rw-r--r--src/bank-lib/fakebank.c17
-rw-r--r--src/exchange/taler-exchange-httpd.c10
-rw-r--r--src/exchange/taler-exchange-httpd_db.c12
-rw-r--r--src/exchange/taler-exchange-httpd_deposit.c24
-rw-r--r--src/exchange/taler-exchange-httpd_deposits_get.c16
-rw-r--r--src/exchange/taler-exchange-httpd_keystate.c10
-rw-r--r--src/exchange/taler-exchange-httpd_link.c6
-rw-r--r--src/exchange/taler-exchange-httpd_melt.c61
-rw-r--r--src/exchange/taler-exchange-httpd_recoup.c22
-rw-r--r--src/exchange/taler-exchange-httpd_refreshes_reveal.c53
-rw-r--r--src/exchange/taler-exchange-httpd_refund.c54
-rw-r--r--src/exchange/taler-exchange-httpd_reserves_get.c16
-rw-r--r--src/exchange/taler-exchange-httpd_responses.c6
-rw-r--r--src/exchange/taler-exchange-httpd_transfers_get.c12
-rw-r--r--src/exchange/taler-exchange-httpd_withdraw.c48
-rw-r--r--src/include/taler_mhd_lib.h8
-rw-r--r--src/json/json.c3
-rw-r--r--src/mhd/mhd_legal.c1
-rw-r--r--src/mhd/mhd_parsing.c78
-rw-r--r--src/mhd/mhd_responses.c18
23 files changed, 257 insertions, 234 deletions
diff --git a/contrib/gana b/contrib/gana
-Subproject bc9def4616494c85af54418bb11193c42f08763
+Subproject 4c0be7d53a083926c2dcc8e3781d650243466e8
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation.c b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
index e60e5c02e..7ee5ead43 100644
--- a/src/auditor/taler-auditor-httpd_deposit-confirmation.c
+++ b/src/auditor/taler-auditor-httpd_deposit-confirmation.c
@@ -86,7 +86,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
- "master_sig (expired)");
+ "master signature expired");
}
/* check our cache */
@@ -105,7 +105,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_SETUP_FAILED,
- "failed to establish session with database");
+ NULL);
}
if (! cached)
{
@@ -120,7 +120,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
- "master_sig");
+ "master signature invalid");
}
/* execute transaction */
@@ -134,7 +134,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_AUDITOR_EXCHANGE_STORE_DB_ERROR,
- "failed to persist exchange signing key");
+ NULL);
}
/* Cache it, due to concurreny it might already be in the cache,
@@ -174,7 +174,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
- "exchange_sig");
+ "exchange signature invalid");
}
}
@@ -189,7 +189,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR,
- "failed to persist deposit-confirmation data");
+ NULL);
}
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
diff --git a/src/auditor/taler-auditor-httpd_exchanges.c b/src/auditor/taler-auditor-httpd_exchanges.c
index f117b6083..ffa215ec2 100644
--- a/src/auditor/taler-auditor-httpd_exchanges.c
+++ b/src/auditor/taler-auditor-httpd_exchanges.c
@@ -90,7 +90,7 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_SETUP_FAILED,
- "failed to establish session with database");
+ NULL);
}
ja = json_array ();
GNUNET_break (NULL != ja);
@@ -106,7 +106,7 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_LIST_EXCHANGES_DB_ERROR,
- "Could not fetch exchange list from database");
+ NULL);
}
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
diff --git a/src/bank-lib/fakebank.c b/src/bank-lib/fakebank.c
index 699acb51b..990052e88 100644
--- a/src/bank-lib/fakebank.c
+++ b/src/bank-lib/fakebank.c
@@ -760,14 +760,19 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
&row_id);
if (GNUNET_OK != ret)
{
+ MHD_RESULT res;
+ char *uids;
+
GNUNET_break (0);
+ uids = GNUNET_STRINGS_data_to_string_alloc (&uuid,
+ sizeof (uuid));
json_decref (json);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_CONFLICT,
- TALER_EC_BANK_TRANSFER_REQUEST_UID_REUSED,
- "transfer request UID was reused");
-
-
+ res = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_CONFLICT,
+ TALER_EC_BANK_TRANSFER_REQUEST_UID_REUSED,
+ uids);
+ GNUNET_free (uids);
+ return res;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s, from %s\n",
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 73cc3530d..bc6ab23b3 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -236,7 +236,7 @@ handle_post_coins (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_COINS_INVALID_COIN_PUB,
- "coin public key malformed");
+ args[0]);
}
for (unsigned int i = 0; NULL != h[i].op; i++)
if (0 == strcmp (h[i].op,
@@ -247,7 +247,7 @@ handle_post_coins (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_OPERATION_UNKNOWN,
- "requested operation on coin unknown");
+ args[1]);
}
@@ -331,7 +331,7 @@ proceed_with_handler (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_URI_TOO_LONG,
TALER_EC_URI_TOO_LONG,
- "The URI given is too long");
+ url);
}
/* All POST endpoints come with a body in JSON format. So we parse
@@ -745,7 +745,7 @@ handle_mhd_request (void *cls,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_METHOD_NOT_ALLOWED,
TALER_EC_METHOD_INVALID,
- "The HTTP method used is invalid for this URL");
+ method);
}
}
@@ -756,7 +756,7 @@ handle_mhd_request (void *cls,
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_ENDPOINT_UNKNOWN,
- "No handler found for the given URL");
+ url);
GNUNET_async_scope_restore (&old_scope);
return ret;
}
diff --git a/src/exchange/taler-exchange-httpd_db.c b/src/exchange/taler-exchange-httpd_db.c
index b0e495226..505cf3d92 100644
--- a/src/exchange/taler-exchange-httpd_db.c
+++ b/src/exchange/taler-exchange-httpd_db.c
@@ -74,7 +74,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
= TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_COIN_HISTORY_STORE_ERROR,
- "could not persist coin data");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
case TALER_EXCHANGEDB_CKS_CONFLICT:
break;
@@ -96,7 +96,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
- "could not fetch coin transaction history");
+ NULL);
return qs;
}
*mhd_ret
@@ -146,7 +146,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_SETUP_FAILED,
- "could not establish database session");
+ NULL);
return GNUNET_SYSERR;
}
for (unsigned int retries = 0;
@@ -165,7 +165,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_START_FAILED,
- "could not begin transaction");
+ NULL);
return GNUNET_SYSERR;
}
qs = cb (cb_cls,
@@ -186,7 +186,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_COMMIT_FAILED_HARD,
- "could not commit database transaction");
+ NULL);
return GNUNET_SYSERR;
}
/* make sure callback did not violate invariants! */
@@ -202,7 +202,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_COMMIT_FAILED_ON_RETRY,
- "repatedly failed to serialize database transaction");
+ NULL);
return GNUNET_SYSERR;
}
diff --git a/src/exchange/taler-exchange-httpd_deposit.c b/src/exchange/taler-exchange-httpd_deposit.c
index 0b810220a..25c3d80cf 100644
--- a/src/exchange/taler-exchange-httpd_deposit.c
+++ b/src/exchange/taler-exchange-httpd_deposit.c
@@ -161,7 +161,7 @@ deposit_precheck (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
- "Could not check for existing identical deposit");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
return qs;
@@ -255,7 +255,7 @@ deposit_transaction (void *cls,
connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
- "could not fetch coin transaction history");
+ NULL);
return qs;
}
if (GNUNET_OK !=
@@ -269,7 +269,7 @@ deposit_transaction (void *cls,
connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
- "could not calculate historic coin amount total");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
/* Check that cost of all transactions (including the current one) is
@@ -301,7 +301,7 @@ deposit_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_STORE_DB_ERROR,
- "Could not persist /deposit data");
+ NULL);
}
return qs;
}
@@ -382,7 +382,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE,
- "refund_deadline");
+ NULL);
}
if (GNUNET_OK !=
TALER_JSON_merchant_wire_signature_hash (wire,
@@ -394,7 +394,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON,
- "wire");
+ NULL);
}
if (0 != GNUNET_memcmp (&deposit.h_wire,
&my_h_wire))
@@ -404,7 +404,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT,
- "h_wire");
+ NULL);
}
/* Check for idempotency: did we get this request before? */
@@ -457,7 +457,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
hc,
ec,
- "Could not find denomination key used in deposit");
+ NULL);
}
TALER_amount_ntoh (&deposit.deposit_fee,
&dki->issue.properties.fee_deposit);
@@ -471,7 +471,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_CURRENCY_MISMATCH,
- "contribution");
+ deposit.deposit_fee.currency);
}
/* check coin signature */
if (GNUNET_YES !=
@@ -484,7 +484,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_UNAUTHORIZED,
TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID,
- "ub_sig");
+ NULL);
}
TALER_amount_ntoh (&dc.value,
&dki->issue.properties.value);
@@ -498,7 +498,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE,
- "deposited amount smaller than depositing fee");
+ NULL);
}
/* check deposit signature */
@@ -530,7 +530,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_UNAUTHORIZED,
TALER_EC_DEPOSIT_COIN_SIGNATURE_INVALID,
- "coin_sig");
+ NULL);
}
}
diff --git a/src/exchange/taler-exchange-httpd_deposits_get.c b/src/exchange/taler-exchange-httpd_deposits_get.c
index a2226b7e3..983177aa3 100644
--- a/src/exchange/taler-exchange-httpd_deposits_get.c
+++ b/src/exchange/taler-exchange-httpd_deposits_get.c
@@ -234,7 +234,7 @@ deposits_get_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSITS_GET_DB_FETCH_FAILED,
- "failed to fetch transaction data");
+ NULL);
}
return qs;
}
@@ -243,7 +243,7 @@ deposits_get_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_DEPOSITS_GET_NOT_FOUND,
- "transaction unknown");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
return qs;
@@ -289,7 +289,7 @@ handle_track_transaction_request (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSITS_GET_DB_FEE_INCONSISTENT,
- "fees are inconsistent");
+ NULL);
return reply_deposit_details (connection,
&tps->h_contract_terms,
&tps->h_wire,
@@ -333,7 +333,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_H_WIRE,
- "wire hash malformed");
+ args[0]);
}
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (args[1],
@@ -345,7 +345,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_MERCHANT_PUB,
- "merchant public key malformed");
+ args[1]);
}
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (args[2],
@@ -357,7 +357,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_H_CONTRACT_TERMS,
- "contract terms hash malformed");
+ args[2]);
}
if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (args[3],
@@ -369,7 +369,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_COIN_PUB,
- "coin public key malformed");
+ args[3]);
}
res = TALER_MHD_parse_request_arg_data (connection,
"merchant_sig",
@@ -389,7 +389,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSITS_GET_MERCHANT_SIGNATURE_INVALID,
- "merchant_sig");
+ NULL);
}
return handle_track_transaction_request (connection,
diff --git a/src/exchange/taler-exchange-httpd_keystate.c b/src/exchange/taler-exchange-httpd_keystate.c
index 4439bb945..7f0f20125 100644
--- a/src/exchange/taler-exchange-httpd_keystate.c
+++ b/src/exchange/taler-exchange-httpd_keystate.c
@@ -2502,7 +2502,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_KEYS_HAVE_NOT_NUMERIC,
- "last_issue_date");
+ have_cherrypick);
}
/* The following multiplication may overflow; but this should not really
be a problem, as giving back 'older' data than what the client asks for
@@ -2531,7 +2531,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_KEYS_HAVE_NOT_NUMERIC,
- "now");
+ have_fakenow);
}
if (TEH_allow_keys_timetravel)
{
@@ -2547,7 +2547,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_KEYS_TIMETRAVEL_FORBIDDEN,
- "timetravel not allowed by this exchange");
+ NULL);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -2567,7 +2567,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_EXCHANGE_BAD_CONFIGURATION,
- "no keys for requested time");
+ NULL);
}
krd = bsearch (&last_issue_date,
key_state->krd_array,
@@ -2599,7 +2599,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_KEYS_MISSING,
- "no key response found");
+ NULL);
}
ret = MHD_queue_response (connection,
MHD_HTTP_OK,
diff --git a/src/exchange/taler-exchange-httpd_link.c b/src/exchange/taler-exchange-httpd_link.c
index 948c8eb08..3611db50e 100644
--- a/src/exchange/taler-exchange-httpd_link.c
+++ b/src/exchange/taler-exchange-httpd_link.c
@@ -157,7 +157,7 @@ link_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
ctx->ec,
- "coin_pub");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
@@ -165,7 +165,7 @@ link_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_LINK_COIN_UNKNOWN,
- "coin_pub");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
return qs;
@@ -202,7 +202,7 @@ TEH_handler_link (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_COINS_INVALID_COIN_PUB,
- "coin public key malformed");
+ args[0]);
}
ctx.mlist = json_array ();
if (NULL == ctx.mlist)
diff --git a/src/exchange/taler-exchange-httpd_melt.c b/src/exchange/taler-exchange-httpd_melt.c
index 35cd2359e..4f5f4ceb0 100644
--- a/src/exchange/taler-exchange-httpd_melt.c
+++ b/src/exchange/taler-exchange-httpd_melt.c
@@ -64,25 +64,25 @@ reply_melt_insufficient_funds (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
- "Failed to compile transaction history");
- return TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_CONFLICT,
- "{s:s, s:I, s:o, s:o, s:o, s:o, s:o}",
- "hint",
- "insufficient funds",
- "code",
- (json_int_t)
- TALER_EC_MELT_INSUFFICIENT_FUNDS,
- "coin_pub",
- GNUNET_JSON_from_data_auto (coin_pub),
- "original_value",
- TALER_JSON_from_amount (coin_value),
- "residual_value",
- TALER_JSON_from_amount (residual),
- "requested_value",
- TALER_JSON_from_amount (requested),
- "history",
- history);
+ NULL);
+ return TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_CONFLICT,
+ "{s:s, s:I, s:o, s:o, s:o, s:o, s:o}",
+ TALER_ErrorCode_get_hint (TALER_EC_MELT_INSUFFICIENT_FUNDS),
+ "code",
+ (json_int_t)
+ TALER_EC_MELT_INSUFFICIENT_FUNDS,
+ "coin_pub",
+ GNUNET_JSON_from_data_auto (coin_pub),
+ "original_value",
+ TALER_JSON_from_amount (coin_value),
+ "residual_value",
+ TALER_JSON_from_amount (residual),
+ "requested_value",
+ TALER_JSON_from_amount (requested),
+ "history",
+ history);
}
@@ -202,7 +202,7 @@ refresh_check_melt (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_FETCH_ERROR,
- "failed to fetch old coin history");
+ NULL);
return qs;
}
if (rmc->zombie_required)
@@ -229,7 +229,7 @@ refresh_check_melt (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_MELT_COIN_EXPIRED_NO_ZOMBIE,
- "denomination expired");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
}
@@ -244,7 +244,7 @@ refresh_check_melt (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_COIN_HISTORY_COMPUTATION_FAILED,
- "failed to compute coin transaction history");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -341,7 +341,7 @@ melt_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_FETCH_ERROR,
- "failed to fetch melt index");
+ NULL);
return qs;
}
@@ -367,7 +367,7 @@ melt_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_STORE_SESSION_ERROR,
- "failed to persist melt data");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
return qs;
@@ -417,7 +417,7 @@ handle_melt (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_MELT_COIN_SIGNATURE_INVALID,
- "confirm_sig");
+ NULL);
}
}
@@ -509,7 +509,7 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_FETCH_ERROR,
- "failed to find information about old coin");
+ NULL);
}
/* sanity check */
GNUNET_break (0 ==
@@ -549,7 +549,7 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
hc,
ec,
- "unknown denomination");
+ NULL);
}
TALER_amount_ntoh (&rmc->coin_refresh_fee,
@@ -566,7 +566,8 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_MELT_CURRENCY_MISMATCH,
- "value_with_fee");
+ rmc->refresh_session.amount_with_fee.
+ currency);
}
/* check coin is actually properly signed */
@@ -579,7 +580,7 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_MELT_DENOMINATION_SIGNATURE_INVALID,
- "denom_sig");
+ NULL);
}
}
TEH_KS_release (key_state);
@@ -593,7 +594,7 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_MELT_FEES_EXCEED_CONTRIBUTION,
- "melt amount smaller than melting fee");
+ NULL);
}
return handle_melt (connection,
rmc);
diff --git a/src/exchange/taler-exchange-httpd_recoup.c b/src/exchange/taler-exchange-httpd_recoup.c
index e53c1d9d2..74d725653 100644
--- a/src/exchange/taler-exchange-httpd_recoup.c
+++ b/src/exchange/taler-exchange-httpd_recoup.c
@@ -156,7 +156,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_FETCH_FAILED,
- "failed to fetch old coin of blind coin");
+ NULL);
}
return qs;
}
@@ -175,7 +175,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_FETCH_FAILED,
- "failed to fetch reserve of blinded coin");
+ NULL);
}
return qs;
}
@@ -188,7 +188,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_RECOUP_WITHDRAW_NOT_FOUND,
- "envelope unknown");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -206,7 +206,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_FETCH_FAILED,
- "failed to fetch coin transaction history");
+ NULL);
}
return qs;
}
@@ -241,7 +241,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_HISTORY_DB_ERROR,
- "failed to calculate old coin transaction history");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -261,7 +261,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_COIN_BALANCE_NEGATIVE,
- "calculated negative coin balance");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
if ( (0 == pc->amount.fraction) &&
@@ -328,7 +328,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_PUT_FAILED,
- "failed to persist recoup data");
+ NULL);
}
return qs;
}
@@ -392,7 +392,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
hc,
ec,
- "denomination not valid for recoup");
+ NULL);
}
TALER_amount_ntoh (&pc.value,
&dki->issue.properties.value);
@@ -407,7 +407,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_RECOUP_DENOMINATION_SIGNATURE_INVALID,
- "denom_sig");
+ NULL);
}
/* check recoup request signature */
@@ -431,7 +431,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_RECOUP_SIGNATURE_INVALID,
- "coin_sig");
+ NULL);
}
}
GNUNET_CRYPTO_hash (&coin->coin_pub.eddsa_pub,
@@ -449,7 +449,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_BLINDING_FAILED,
- "coin_bks");
+ NULL);
}
TEH_KS_release (key_state);
}
diff --git a/src/exchange/taler-exchange-httpd_refreshes_reveal.c b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
index e752ce969..09d1a67b7 100644
--- a/src/exchange/taler-exchange-httpd_refreshes_reveal.c
+++ b/src/exchange/taler-exchange-httpd_refreshes_reveal.c
@@ -257,7 +257,7 @@ refreshes_reveal_preflight (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_FETCH_REVEAL_ERROR,
- "failed to fetch reveal data");
+ NULL);
rctx->preflight_ok = GNUNET_SYSERR;
return GNUNET_DB_STATUS_HARD_ERROR;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
@@ -309,7 +309,7 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_REVEAL_SESSION_UNKNOWN,
- "rc");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (GNUNET_DB_STATUS_SOFT_ERROR == qs)
@@ -321,7 +321,7 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR,
- "failed to fetch valid challenge from database");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -409,16 +409,17 @@ refreshes_reveal_transaction (void *cls,
&rc_expected))
{
GNUNET_break_op (0);
- *mhd_ret = TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_CONFLICT,
- "{s:s, s:I, s:o}",
- "hint", "commitment violation",
- "code",
- (json_int_t)
- TALER_EC_REVEAL_COMMITMENT_VIOLATION,
- "rc_expected",
- GNUNET_JSON_from_data_auto (
- &rc_expected));
+ *mhd_ret = TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_CONFLICT,
+ "{s:s, s:I, s:o}",
+ "hint",
+ TALER_ErrorCode_get_hint (TALER_EC_REVEAL_COMMITMENT_VIOLATION),
+ "code",
+ (json_int_t) TALER_EC_REVEAL_COMMITMENT_VIOLATION,
+ "rc_expected",
+ GNUNET_JSON_from_data_auto (
+ &rc_expected));
return GNUNET_DB_STATUS_HARD_ERROR;
}
} /* end of checking "rc_expected" */
@@ -451,7 +452,7 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_COST_CALCULATION_OVERFLOW,
- "failed to add up refresh costs");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
}
@@ -462,7 +463,7 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_AMOUNT_INSUFFICIENT,
- "melted coin value is insufficient to cover cost of operation");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
}
@@ -517,7 +518,7 @@ refreshes_reveal_persist (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_COMMIT_ERROR,
- "failed to persist reveal data");
+ NULL);
}
return qs;
}
@@ -582,7 +583,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
return TALER_MHD_reply_with_error (connection,
hc,
ec,
- "failed to find denomination key");
+ NULL);
}
/* #TEH_KS_DKU_WITHDRAW should warrant that we only get denomination
keys where we did not yet forget the private key */
@@ -630,13 +631,13 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_REVEAL_SESSION_UNKNOWN,
- "rc");
+ NULL);
break;
case GNUNET_DB_STATUS_HARD_ERROR:
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR,
- "failed to fetch session data");
+ NULL);
break;
case GNUNET_DB_STATUS_SOFT_ERROR:
default:
@@ -644,7 +645,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_INTERNAL_INVARIANT_FAILURE,
- "assertion failed (unexpected database serialization error)");
+ NULL);
break;
}
goto cleanup;
@@ -689,7 +690,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_REVEAL_LINK_SIGNATURE_INVALID,
- "link_sig");
+ NULL);
goto cleanup;
}
}
@@ -716,7 +717,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_SIGNING_ERROR,
- "internal signing error");
+ NULL);
goto cleanup;
}
}
@@ -831,7 +832,7 @@ handle_refreshes_reveal_json (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_REVEAL_NEW_DENOMS_ARRAY_SIZE_EXCESSIVE,
- "new_denoms_h");
+ NULL);
}
if (json_array_size (new_denoms_h_json) !=
@@ -945,7 +946,7 @@ TEH_handler_reveal (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_REVEAL_INVALID_RCH,
- "refresh commitment hash malformed");
+ args[0]);
}
if (0 != strcmp (args[1],
"reveal"))
@@ -954,7 +955,7 @@ TEH_handler_reveal (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_OPERATION_INVALID,
- "expected 'reveal' operation");
+ args[1]);
}
{
@@ -979,7 +980,7 @@ TEH_handler_reveal (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_REVEAL_CNC_TRANSFER_ARRAY_SIZE_INVALID,
- "transfer_privs");
+ NULL);
}
{
diff --git a/src/exchange/taler-exchange-httpd_refund.c b/src/exchange/taler-exchange-httpd_refund.c
index 955f1c51d..ea258d1b2 100644
--- a/src/exchange/taler-exchange-httpd_refund.c
+++ b/src/exchange/taler-exchange-httpd_refund.c
@@ -125,9 +125,9 @@ refund_transaction (void *cls,
{
if (GNUNET_DB_STATUS_HARD_ERROR == qs)
*mhd_ret = TALER_MHD_reply_with_error (connection,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_REFUND_COIN_NOT_FOUND,
- "database transaction failure");
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ TALER_EC_REFUND_DATABASE_LOOKUP_ERROR,
+ NULL);
return qs;
}
deposit_found = false;
@@ -163,7 +163,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_GONE,
TALER_EC_REFUND_MERCHANT_ALREADY_PAID,
- "money already sent to merchant");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -230,9 +230,11 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_PRECONDITION_FAILED,
- "{s:s, s:I, s:o}",
- "hint",
+ "{s:s, s:s, s:I, s:o}",
+ "detail",
"conflicting refund with different amount but same refund transaction ID",
+ "hint", TALER_ErrorCode_get_hint (
+ TALER_EC_REFUND_INCONSISTENT_AMOUNT),
"code", (json_int_t) TALER_EC_REFUND_INCONSISTENT_AMOUNT,
"history", TEH_RESPONSE_compile_transaction_history (
&refund->coin.coin_pub,
@@ -306,7 +308,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_REFUND_DEPOSIT_NOT_FOUND,
- "deposit unknown");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -321,7 +323,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_REFUND_CURRENCY_MISMATCH,
- "currencies involved do not match");
+ deposit_total.currency);
return GNUNET_DB_STATUS_HARD_ERROR;
}
@@ -340,13 +342,16 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_CONFLICT,
- "{s:s, s:I, s:o}",
- "hint",
+ "{s:s, s:s, s:I, s:o}",
+ "detail",
"total amount refunded exceeds total amount deposited for this coin",
- "code", (json_int_t) TALER_EC_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT,
- "history", TEH_RESPONSE_compile_transaction_history (
- &refund->coin.coin_pub,
- tlx));
+ "hint",
+ TALER_ErrorCode_get_hint (TALER_EC_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT),
+ "code",
+ (json_int_t) TALER_EC_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT,
+ "history",
+ TEH_RESPONSE_compile_transaction_history (&refund->coin.coin_pub,
+ tlx));
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tlx);
return GNUNET_DB_STATUS_HARD_ERROR;
@@ -365,7 +370,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REFUND_STORE_DB_ERROR,
- "could not persist store information");
+ NULL);
return qs;
}
/* Success or soft failure */
@@ -411,7 +416,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID,
- "merchant_sig");
+ NULL);
}
}
@@ -425,11 +430,18 @@ verify_and_execute_refund (struct MHD_Connection *connection,
&denom_hash);
if (0 > qs)
{
+ MHD_RESULT res;
+ char *dhs;
+
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
- return TALER_MHD_reply_with_error (connection,
- MHD_HTTP_NOT_FOUND,
- TALER_EC_REFUND_COIN_NOT_FOUND,
- "denomination of coin to be refunded not found in DB");
+ dhs = GNUNET_STRINGS_data_to_string_alloc (&denom_hash,
+ sizeof (denom_hash));
+ res = TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_REFUND_COIN_NOT_FOUND,
+ dhs);
+ GNUNET_free (dhs);
+ return res;
}
}
@@ -465,7 +477,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
hc,
ec,
- "denomination not found, but coin known");
+ NULL);
}
TALER_amount_ntoh (&refund->details.refund_fee,
&dki->issue.properties.fee_refund);
diff --git a/src/exchange/taler-exchange-httpd_reserves_get.c b/src/exchange/taler-exchange-httpd_reserves_get.c
index cbc6b422b..2272e6d03 100644
--- a/src/exchange/taler-exchange-httpd_reserves_get.c
+++ b/src/exchange/taler-exchange-httpd_reserves_get.c
@@ -51,7 +51,7 @@ reply_reserve_history_success (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RESERVE_STATUS_DB_ERROR,
- "balance calculation failure");
+ NULL);
json_balance = TALER_JSON_from_amount (&balance);
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
@@ -143,7 +143,7 @@ TEH_handler_reserves_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_RESERVES_INVALID_RESERVE_PUB,
- "reserve public key malformed");
+ args[0]);
}
rsc.rh = NULL;
if (GNUNET_OK !=
@@ -156,14 +156,10 @@ TEH_handler_reserves_get (const struct TEH_RequestHandler *rh,
/* generate proper response */
if (NULL == rsc.rh)
- return TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_NOT_FOUND,
- "{s:s, s:s, s:I}",
- "hint", "Reserve not found",
- "parameter", "reserve_pub",
- "code",
- (json_int_t)
- TALER_EC_RESERVE_STATUS_UNKNOWN);
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_NOT_FOUND,
+ TALER_EC_RESERVE_STATUS_UNKNOWN,
+ args[0]);
mhd_ret = reply_reserve_history_success (connection,
rsc.rh);
TEH_plugin->free_reserve_history (TEH_plugin->cls,
diff --git a/src/exchange/taler-exchange-httpd_responses.c b/src/exchange/taler-exchange-httpd_responses.c
index 4bcb9e7a5..d7d118615 100644
--- a/src/exchange/taler-exchange-httpd_responses.c
+++ b/src/exchange/taler-exchange-httpd_responses.c
@@ -445,13 +445,13 @@ TEH_RESPONSE_reply_coin_insufficient_funds (
GNUNET_break (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
- TALER_EC_COIN_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
- "failed to convert transaction history to JSON");
+ TALER_EC_JSON_ALLOCATION_FAILURE,
+ "Failed to generated proof of insufficient funds");
}
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o}",
- "hint", "insufficient funds",
+ "hint", TALER_ErrorCode_get_hint (ec),
"code", (json_int_t) ec,
"history", history);
}
diff --git a/src/exchange/taler-exchange-httpd_transfers_get.c b/src/exchange/taler-exchange-httpd_transfers_get.c
index 30018a497..7cf37b375 100644
--- a/src/exchange/taler-exchange-httpd_transfers_get.c
+++ b/src/exchange/taler-exchange-httpd_transfers_get.c
@@ -446,7 +446,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_DB_FETCH_FAILED,
- "failed to fetch transaction data");
+ NULL);
}
return qs;
}
@@ -456,7 +456,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_DB_INCONSISTENT,
- "exchange database internally inconsistent");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (GNUNET_NO == ctx->is_valid)
@@ -464,7 +464,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_TRANSFERS_GET_WTID_NOT_FOUND,
- "wtid");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
qs = TEH_plugin->get_wire_fee (TEH_plugin->cls,
@@ -485,7 +485,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_WIRE_FEE_NOT_FOUND,
- "did not find wire fee");
+ NULL);
}
return qs;
}
@@ -498,7 +498,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_WIRE_FEE_INCONSISTENT,
- "could not subtract wire fee");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT;
@@ -535,7 +535,7 @@ TEH_handler_transfers_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_TRANSFERS_INVALID_WTID,
- "wire transfer identifier malformed");
+ args[0]);
}
if (GNUNET_OK !=
TEH_DB_run_transaction (connection,
diff --git a/src/exchange/taler-exchange-httpd_withdraw.c b/src/exchange/taler-exchange-httpd_withdraw.c
index c4c72d6a4..f39f08971 100644
--- a/src/exchange/taler-exchange-httpd_withdraw.c
+++ b/src/exchange/taler-exchange-httpd_withdraw.c
@@ -66,7 +66,7 @@ reply_withdraw_insufficient_funds (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
- "reserve balance calculation failure");
+ NULL);
if (0 !=
TALER_amount_cmp (&balance,
ebalance))
@@ -76,18 +76,20 @@ reply_withdraw_insufficient_funds (
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_RESERVE_BALANCE_CORRUPT,
- "internal balance inconsistency error");
+ NULL);
}
- return TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_CONFLICT,
- "{s:s, s:I, s:o, s:o}",
- "hint", "insufficient funds",
- "code",
- (json_int_t)
- TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS,
- "balance", TALER_JSON_from_amount (
- &balance),
- "history", json_history);
+ return TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_CONFLICT,
+ "{s:s, s:I, s:o, s:o}",
+ "hint",
+ TALER_ErrorCode_get_hint (TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS),
+ "code",
+ (json_int_t) TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS,
+ "balance",
+ TALER_JSON_from_amount (&balance),
+ "history",
+ json_history);
}
@@ -197,7 +199,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_FETCH_ERROR,
- "failed to fetch withdraw data");
+ NULL);
wc->collectable.sig = denom_sig;
return qs;
}
@@ -232,7 +234,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_FETCH_ERROR,
- "failed to fetch reserve data");
+ NULL);
return qs;
}
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
@@ -240,7 +242,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_WITHDRAW_RESERVE_UNKNOWN,
- "reserve_pub");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
if (0 < TALER_amount_cmp (&wc->amount_required,
@@ -274,7 +276,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_FETCH_ERROR,
- "failed to fetch reserve history");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
*mhd_ret = reply_withdraw_insufficient_funds (connection,
@@ -299,7 +301,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_SIGNATURE_FAILED,
- "Failed to create blind signature");
+ NULL);
return GNUNET_DB_STATUS_HARD_ERROR;
}
}
@@ -319,7 +321,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_STORE_ERROR,
- "failed to persist withdraw data");
+ NULL);
return qs;
}
return qs;
@@ -370,7 +372,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_RESERVES_INVALID_RESERVE_PUB,
- "reserve public key malformed");
+ args[0]);
}
{
@@ -408,7 +410,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
hc,
ec,
- "could not find denomination key");
+ NULL);
}
}
GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key);
@@ -430,7 +432,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW,
- "amount overflow for value plus withdraw fee");
+ NULL);
}
TALER_amount_hton (&wc.wsrd.amount_with_fee,
&wc.amount_required);
@@ -459,7 +461,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN,
TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID,
- "reserve_sig");
+ NULL);
}
#if OPTIMISTIC_SIGN
@@ -476,7 +478,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_SIGNATURE_FAILED,
- "Failed to sign");
+ NULL);
}
#endif
diff --git a/src/include/taler_mhd_lib.h b/src/include/taler_mhd_lib.h
index 4b34f41df..09e22f9e1 100644
--- a/src/include/taler_mhd_lib.h
+++ b/src/include/taler_mhd_lib.h
@@ -133,14 +133,14 @@ TALER_MHD_reply_json_pack (struct MHD_Connection *connection,
* @param connection the MHD connection to use
* @param ec error code uniquely identifying the error
* @param http_status HTTP status code to use
- * @param hint human readable hint about the error
+ * @param detail additional optional detail about the error
* @return a MHD result code
*/
MHD_RESULT
TALER_MHD_reply_with_error (struct MHD_Connection *connection,
unsigned int http_status,
enum TALER_ErrorCode ec,
- const char *hint);
+ const char *detail);
/**
@@ -169,12 +169,12 @@ TALER_MHD_make_json_pack (const char *fmt,
* Create a response indicating an internal error.
*
* @param ec error code to return
- * @param hint hint about the internal error's nature
+ * @param detail additional optional detail about the error, can be NULL
* @return a MHD response object
*/
struct MHD_Response *
TALER_MHD_make_error (enum TALER_ErrorCode ec,
- const char *hint);
+ const char *detail);
/**
diff --git a/src/json/json.c b/src/json/json.c
index 09cc757c9..266857198 100644
--- a/src/json/json.c
+++ b/src/json/json.c
@@ -651,7 +651,8 @@ TALER_JSON_get_error_hint (const json_t *json)
GNUNET_break_op (0);
return NULL;
}
- jc = json_object_get (json, "hint");
+ jc = json_object_get (json,
+ "hint");
if (NULL == jc)
return NULL; /* no hint, is allowed */
if (! json_is_string (jc))
diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c
index 0f2433c2c..d505f662f 100644
--- a/src/mhd/mhd_legal.c
+++ b/src/mhd/mhd_legal.c
@@ -24,6 +24,7 @@
#include <gnunet/gnunet_json_lib.h>
#include <jansson.h>
#include <microhttpd.h>
+#include "taler_util.h"
#include "taler_mhd_lib.h"
diff --git a/src/mhd/mhd_parsing.c b/src/mhd/mhd_parsing.c
index 2a086e117..a9f627491 100644
--- a/src/mhd/mhd_parsing.c
+++ b/src/mhd/mhd_parsing.c
@@ -76,11 +76,11 @@ TALER_MHD_parse_post_json (struct MHD_Connection *connection,
case GNUNET_JSON_PR_OUT_OF_MEMORY:
GNUNET_break (NULL == *json);
return (MHD_NO ==
- TALER_MHD_reply_with_error
- (connection,
+ TALER_MHD_reply_with_error (
+ connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_PARSER_OUT_OF_MEMORY,
- "out of memory")) ? GNUNET_SYSERR : GNUNET_NO;
+ NULL)) ? GNUNET_SYSERR : GNUNET_NO;
case GNUNET_JSON_PR_CONTINUE:
GNUNET_break (NULL == *json);
@@ -96,7 +96,7 @@ TALER_MHD_parse_post_json (struct MHD_Connection *connection,
TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST,
TALER_EC_JSON_INVALID,
- "invalid JSON uploaded"))
+ NULL))
? GNUNET_NO : GNUNET_SYSERR;
case GNUNET_JSON_PR_SUCCESS:
GNUNET_break (NULL != *json);
@@ -204,15 +204,15 @@ TALER_MHD_parse_json_data (struct MHD_Connection *connection,
if (NULL == error_json_name)
error_json_name = "<no field>";
ret = (MHD_YES ==
- TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_BAD_REQUEST,
- "{s:s, s:I, s:s, s:I}",
- "hint", "JSON parse error",
- "code",
- (json_int_t)
- TALER_EC_JSON_INVALID_WITH_DETAILS,
- "field", error_json_name,
- "line", (json_int_t) error_line))
+ TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ "{s:s, s:I, s:s, s:I}",
+ "hint", TALER_ErrorCode_get_hint (
+ TALER_EC_JSON_INVALID_WITH_DETAILS),
+ "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS,
+ "field", error_json_name,
+ "line", (json_int_t) error_line))
? GNUNET_NO : GNUNET_SYSERR;
return ret;
}
@@ -256,15 +256,15 @@ TALER_MHD_parse_internal_json_data (struct MHD_Connection *connection,
if (NULL == error_json_name)
error_json_name = "<no field>";
ret = (MHD_YES ==
- TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- "{s:s, s:I, s:s, s:I}",
- "hint", "JSON parse error",
- "code",
- (json_int_t)
- TALER_EC_INTERNAL_INVARIANT_FAILURE,
- "field", error_json_name,
- "line", (json_int_t) error_line))
+ TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ "{s:s, s:I, s:s, s:I}",
+ "hint", TALER_ErrorCode_get_hint (
+ TALER_EC_INTERNAL_INVARIANT_FAILURE),
+ "code", (json_int_t) TALER_EC_INTERNAL_INVARIANT_FAILURE,
+ "field", error_json_name,
+ "line", (json_int_t) error_line))
? GNUNET_NO : GNUNET_SYSERR;
return ret;
}
@@ -311,14 +311,15 @@ TALER_MHD_parse_json_array (struct MHD_Connection *connection,
if (NULL == root)
{
ret = (MHD_YES ==
- TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_BAD_REQUEST,
- "{s:s, s:I, s:I}",
- "hint", "expected array",
- "code",
- (json_int_t)
- TALER_EC_JSON_INVALID_WITH_DETAILS,
- "dimension", dim))
+ TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ "{s:s, s:I, s:s, s:I}",
+ "hint", TALER_ErrorCode_get_hint (
+ TALER_EC_JSON_INVALID_WITH_DETAILS),
+ "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS,
+ "detail", "expected array",
+ "dimension", dim))
? GNUNET_NO : GNUNET_SYSERR;
return ret;
}
@@ -331,14 +332,15 @@ TALER_MHD_parse_json_array (struct MHD_Connection *connection,
if (NULL == error_json_name)
error_json_name = "<no field>";
ret = (MHD_YES ==
- TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_BAD_REQUEST,
- "{s:s, s:I, s:I}",
- "hint", error_json_name,
- "code",
- (json_int_t)
- TALER_EC_JSON_INVALID_WITH_DETAILS,
- "line", (json_int_t) error_line))
+ TALER_MHD_reply_json_pack (
+ connection,
+ MHD_HTTP_BAD_REQUEST,
+ "{s:s, s:s, s:I, s:I}",
+ "detail", error_json_name,
+ "hint", TALER_ErrorCode_get_hint (
+ TALER_EC_JSON_INVALID_WITH_DETAILS),
+ "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS,
+ "line", (json_int_t) error_line))
? GNUNET_NO : GNUNET_SYSERR;
return ret;
}
diff --git a/src/mhd/mhd_responses.c b/src/mhd/mhd_responses.c
index 45a9932d3..5ed82cd2a 100644
--- a/src/mhd/mhd_responses.c
+++ b/src/mhd/mhd_responses.c
@@ -404,16 +404,17 @@ TALER_MHD_make_json_pack (const char *fmt,
* Create a response indicating an internal error.
*
* @param ec error code to return
- * @param hint hint about the internal error's nature
+ * @param detail additional optional detail about the error, can be NULL
* @return a MHD response object
*/
struct MHD_Response *
TALER_MHD_make_error (enum TALER_ErrorCode ec,
- const char *hint)
+ const char *detail)
{
- return TALER_MHD_make_json_pack ("{s:I, s:s}",
+ return TALER_MHD_make_json_pack ("{s:I, s:s, s:s?}",
"code", (json_int_t) ec,
- "hint", hint);
+ "hint", TALER_ErrorCode_get_hint (ec),
+ "detail", detail);
}
@@ -423,20 +424,21 @@ TALER_MHD_make_error (enum TALER_ErrorCode ec,
* @param connection the MHD connection to use
* @param ec error code uniquely identifying the error
* @param http_status HTTP status code to use
- * @param hint human readable hint about the error
+ * @param detail additional optional detail about the error, can be NULL
* @return a MHD result code
*/
MHD_RESULT
TALER_MHD_reply_with_error (struct MHD_Connection *connection,
unsigned int http_status,
enum TALER_ErrorCode ec,
- const char *hint)
+ const char *detail)
{
return TALER_MHD_reply_json_pack (connection,
http_status,
- "{s:I, s:s}",
+ "{s:I, s:s, s:s?}",
"code", (json_int_t) ec,
- "hint", hint);
+ "hint", TALER_ErrorCode_get_hint (ec),
+ "detail", detail);
}