nicer generic error reporting logic, for #6432

This commit is contained in:
Christian Grothoff 2020-08-25 15:11:56 +02:00
parent ce266ce8f2
commit 4bba726356
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
23 changed files with 258 additions and 235 deletions

@ -1 +1 @@
Subproject commit bc9def4616494c85af54418bb11193c42f087634 Subproject commit 4c0be7d53a083926c2dcc8e3781d650243466e89

View File

@ -86,7 +86,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
"master_sig (expired)"); "master signature expired");
} }
/* check our cache */ /* check our cache */
@ -105,7 +105,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_SETUP_FAILED, TALER_EC_DB_SETUP_FAILED,
"failed to establish session with database"); NULL);
} }
if (! cached) if (! cached)
{ {
@ -120,7 +120,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID,
"master_sig"); "master signature invalid");
} }
/* execute transaction */ /* execute transaction */
@ -134,7 +134,7 @@ verify_and_execute_deposit_confirmation (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_AUDITOR_EXCHANGE_STORE_DB_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, /* 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSIT_CONFIRMATION_SIGNATURE_INVALID, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR, TALER_EC_DEPOSIT_CONFIRMATION_STORE_DB_ERROR,
"failed to persist deposit-confirmation data"); NULL);
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,

View File

@ -90,7 +90,7 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_SETUP_FAILED, TALER_EC_DB_SETUP_FAILED,
"failed to establish session with database"); NULL);
} }
ja = json_array (); ja = json_array ();
GNUNET_break (NULL != ja); GNUNET_break (NULL != ja);
@ -106,7 +106,7 @@ TAH_EXCHANGES_handler (struct TAH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_LIST_EXCHANGES_DB_ERROR, TALER_EC_LIST_EXCHANGES_DB_ERROR,
"Could not fetch exchange list from database"); NULL);
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,

View File

@ -760,14 +760,19 @@ handle_transfer (struct TALER_FAKEBANK_Handle *h,
&row_id); &row_id);
if (GNUNET_OK != ret) if (GNUNET_OK != ret)
{ {
MHD_RESULT res;
char *uids;
GNUNET_break (0); GNUNET_break (0);
uids = GNUNET_STRINGS_data_to_string_alloc (&uuid,
sizeof (uuid));
json_decref (json); json_decref (json);
return TALER_MHD_reply_with_error (connection, res = TALER_MHD_reply_with_error (connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
TALER_EC_BANK_TRANSFER_REQUEST_UID_REUSED, TALER_EC_BANK_TRANSFER_REQUEST_UID_REUSED,
"transfer request UID was reused"); uids);
GNUNET_free (uids);
return res;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s, from %s\n", "Receiving incoming wire transfer: %s->%s, subject: %s, amount: %s, from %s\n",

View File

@ -236,7 +236,7 @@ handle_post_coins (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_COINS_INVALID_COIN_PUB, TALER_EC_COINS_INVALID_COIN_PUB,
"coin public key malformed"); args[0]);
} }
for (unsigned int i = 0; NULL != h[i].op; i++) for (unsigned int i = 0; NULL != h[i].op; i++)
if (0 == strcmp (h[i].op, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_OPERATION_UNKNOWN, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_URI_TOO_LONG, MHD_HTTP_URI_TOO_LONG,
TALER_EC_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 /* 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_METHOD_NOT_ALLOWED, MHD_HTTP_METHOD_NOT_ALLOWED,
TALER_EC_METHOD_INVALID, 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, ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_ENDPOINT_UNKNOWN, TALER_EC_ENDPOINT_UNKNOWN,
"No handler found for the given URL"); url);
GNUNET_async_scope_restore (&old_scope); GNUNET_async_scope_restore (&old_scope);
return ret; return ret;
} }

View File

@ -74,7 +74,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
= TALER_MHD_reply_with_error (connection, = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_COIN_HISTORY_STORE_ERROR, TALER_EC_DB_COIN_HISTORY_STORE_ERROR,
"could not persist coin data"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
case TALER_EXCHANGEDB_CKS_CONFLICT: case TALER_EXCHANGEDB_CKS_CONFLICT:
break; break;
@ -96,7 +96,7 @@ TEH_make_coin_known (const struct TALER_CoinPublicInfo *coin,
connection, connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR, TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
"could not fetch coin transaction history"); NULL);
return qs; return qs;
} }
*mhd_ret *mhd_ret
@ -146,7 +146,7 @@ TEH_DB_run_transaction (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_SETUP_FAILED, TALER_EC_DB_SETUP_FAILED,
"could not establish database session"); NULL);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
for (unsigned int retries = 0; 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_START_FAILED, TALER_EC_DB_START_FAILED,
"could not begin transaction"); NULL);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
qs = cb (cb_cls, 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_COMMIT_FAILED_HARD, TALER_EC_DB_COMMIT_FAILED_HARD,
"could not commit database transaction"); NULL);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }
/* make sure callback did not violate invariants! */ /* 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DB_COMMIT_FAILED_ON_RETRY, TALER_EC_DB_COMMIT_FAILED_ON_RETRY,
"repatedly failed to serialize database transaction"); NULL);
return GNUNET_SYSERR; return GNUNET_SYSERR;
} }

View File

@ -161,7 +161,7 @@ deposit_precheck (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR, TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
"Could not check for existing identical deposit"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
return qs; return qs;
@ -255,7 +255,7 @@ deposit_transaction (void *cls,
connection, connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR, TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
"could not fetch coin transaction history"); NULL);
return qs; return qs;
} }
if (GNUNET_OK != if (GNUNET_OK !=
@ -269,7 +269,7 @@ deposit_transaction (void *cls,
connection, connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_HISTORY_DB_ERROR, TALER_EC_DEPOSIT_HISTORY_DB_ERROR,
"could not calculate historic coin amount total"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
/* Check that cost of all transactions (including the current one) is /* 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSIT_STORE_DB_ERROR, TALER_EC_DEPOSIT_STORE_DB_ERROR,
"Could not persist /deposit data"); NULL);
} }
return qs; return qs;
} }
@ -382,7 +382,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE, TALER_EC_DEPOSIT_REFUND_DEADLINE_AFTER_WIRE_DEADLINE,
"refund_deadline"); NULL);
} }
if (GNUNET_OK != if (GNUNET_OK !=
TALER_JSON_merchant_wire_signature_hash (wire, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON, TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_JSON,
"wire"); NULL);
} }
if (0 != GNUNET_memcmp (&deposit.h_wire, if (0 != GNUNET_memcmp (&deposit.h_wire,
&my_h_wire)) &my_h_wire))
@ -404,7 +404,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT, TALER_EC_DEPOSIT_INVALID_WIRE_FORMAT_CONTRACT_HASH_CONFLICT,
"h_wire"); NULL);
} }
/* Check for idempotency: did we get this request before? */ /* 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, return TALER_MHD_reply_with_error (connection,
hc, hc,
ec, ec,
"Could not find denomination key used in deposit"); NULL);
} }
TALER_amount_ntoh (&deposit.deposit_fee, TALER_amount_ntoh (&deposit.deposit_fee,
&dki->issue.properties.fee_deposit); &dki->issue.properties.fee_deposit);
@ -471,7 +471,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_CURRENCY_MISMATCH, TALER_EC_DEPOSIT_CURRENCY_MISMATCH,
"contribution"); deposit.deposit_fee.currency);
} }
/* check coin signature */ /* check coin signature */
if (GNUNET_YES != if (GNUNET_YES !=
@ -484,7 +484,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_UNAUTHORIZED, MHD_HTTP_UNAUTHORIZED,
TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID, TALER_EC_DEPOSIT_DENOMINATION_SIGNATURE_INVALID,
"ub_sig"); NULL);
} }
TALER_amount_ntoh (&dc.value, TALER_amount_ntoh (&dc.value,
&dki->issue.properties.value); &dki->issue.properties.value);
@ -498,7 +498,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE, TALER_EC_DEPOSIT_NEGATIVE_VALUE_AFTER_FEE,
"deposited amount smaller than depositing fee"); NULL);
} }
/* check deposit signature */ /* check deposit signature */
@ -530,7 +530,7 @@ TEH_handler_deposit (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_UNAUTHORIZED, MHD_HTTP_UNAUTHORIZED,
TALER_EC_DEPOSIT_COIN_SIGNATURE_INVALID, TALER_EC_DEPOSIT_COIN_SIGNATURE_INVALID,
"coin_sig"); NULL);
} }
} }

View File

@ -234,7 +234,7 @@ deposits_get_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSITS_GET_DB_FETCH_FAILED, TALER_EC_DEPOSITS_GET_DB_FETCH_FAILED,
"failed to fetch transaction data"); NULL);
} }
return qs; return qs;
} }
@ -243,7 +243,7 @@ deposits_get_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_DEPOSITS_GET_NOT_FOUND, TALER_EC_DEPOSITS_GET_NOT_FOUND,
"transaction unknown"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
return qs; return qs;
@ -289,7 +289,7 @@ handle_track_transaction_request (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_DEPOSITS_GET_DB_FEE_INCONSISTENT, TALER_EC_DEPOSITS_GET_DB_FEE_INCONSISTENT,
"fees are inconsistent"); NULL);
return reply_deposit_details (connection, return reply_deposit_details (connection,
&tps->h_contract_terms, &tps->h_contract_terms,
&tps->h_wire, &tps->h_wire,
@ -333,7 +333,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_H_WIRE, TALER_EC_DEPOSITS_INVALID_H_WIRE,
"wire hash malformed"); args[0]);
} }
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (args[1], 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_MERCHANT_PUB, TALER_EC_DEPOSITS_INVALID_MERCHANT_PUB,
"merchant public key malformed"); args[1]);
} }
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (args[2], 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_H_CONTRACT_TERMS, TALER_EC_DEPOSITS_INVALID_H_CONTRACT_TERMS,
"contract terms hash malformed"); args[2]);
} }
if (GNUNET_OK != if (GNUNET_OK !=
GNUNET_STRINGS_string_to_data (args[3], 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_DEPOSITS_INVALID_COIN_PUB, TALER_EC_DEPOSITS_INVALID_COIN_PUB,
"coin public key malformed"); args[3]);
} }
res = TALER_MHD_parse_request_arg_data (connection, res = TALER_MHD_parse_request_arg_data (connection,
"merchant_sig", "merchant_sig",
@ -389,7 +389,7 @@ TEH_handler_deposits_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_DEPOSITS_GET_MERCHANT_SIGNATURE_INVALID, TALER_EC_DEPOSITS_GET_MERCHANT_SIGNATURE_INVALID,
"merchant_sig"); NULL);
} }
return handle_track_transaction_request (connection, return handle_track_transaction_request (connection,

View File

@ -2502,7 +2502,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_KEYS_HAVE_NOT_NUMERIC, TALER_EC_KEYS_HAVE_NOT_NUMERIC,
"last_issue_date"); have_cherrypick);
} }
/* The following multiplication may overflow; but this should not really /* The following multiplication may overflow; but this should not really
be a problem, as giving back 'older' data than what the client asks for 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_KEYS_HAVE_NOT_NUMERIC, TALER_EC_KEYS_HAVE_NOT_NUMERIC,
"now"); have_fakenow);
} }
if (TEH_allow_keys_timetravel) if (TEH_allow_keys_timetravel)
{ {
@ -2547,7 +2547,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_KEYS_TIMETRAVEL_FORBIDDEN, TALER_EC_KEYS_TIMETRAVEL_FORBIDDEN,
"timetravel not allowed by this exchange"); NULL);
} }
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_EXCHANGE_BAD_CONFIGURATION, TALER_EC_EXCHANGE_BAD_CONFIGURATION,
"no keys for requested time"); NULL);
} }
krd = bsearch (&last_issue_date, krd = bsearch (&last_issue_date,
key_state->krd_array, key_state->krd_array,
@ -2599,7 +2599,7 @@ TEH_handler_keys (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_KEYS_MISSING, TALER_EC_KEYS_MISSING,
"no key response found"); NULL);
} }
ret = MHD_queue_response (connection, ret = MHD_queue_response (connection,
MHD_HTTP_OK, MHD_HTTP_OK,

View File

@ -157,7 +157,7 @@ link_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
ctx->ec, ctx->ec,
"coin_pub"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_LINK_COIN_UNKNOWN, TALER_EC_LINK_COIN_UNKNOWN,
"coin_pub"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
return qs; return qs;
@ -202,7 +202,7 @@ TEH_handler_link (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_COINS_INVALID_COIN_PUB, TALER_EC_COINS_INVALID_COIN_PUB,
"coin public key malformed"); args[0]);
} }
ctx.mlist = json_array (); ctx.mlist = json_array ();
if (NULL == ctx.mlist) if (NULL == ctx.mlist)

View File

@ -64,12 +64,12 @@ reply_melt_insufficient_funds (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, TALER_EC_MELT_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
"Failed to compile transaction history"); NULL);
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o, s:o, s:o, s:o, s:o}", "{s:s, s:I, s:o, s:o, s:o, s:o, s:o}",
"hint", TALER_ErrorCode_get_hint (TALER_EC_MELT_INSUFFICIENT_FUNDS),
"insufficient funds",
"code", "code",
(json_int_t) (json_int_t)
TALER_EC_MELT_INSUFFICIENT_FUNDS, TALER_EC_MELT_INSUFFICIENT_FUNDS,
@ -202,7 +202,7 @@ refresh_check_melt (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_FETCH_ERROR, TALER_EC_MELT_DB_FETCH_ERROR,
"failed to fetch old coin history"); NULL);
return qs; return qs;
} }
if (rmc->zombie_required) if (rmc->zombie_required)
@ -229,7 +229,7 @@ refresh_check_melt (struct MHD_Connection *connection,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_MELT_COIN_EXPIRED_NO_ZOMBIE, TALER_EC_MELT_COIN_EXPIRED_NO_ZOMBIE,
"denomination expired"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_COIN_HISTORY_COMPUTATION_FAILED, TALER_EC_MELT_COIN_HISTORY_COMPUTATION_FAILED,
"failed to compute coin transaction history"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
@ -341,7 +341,7 @@ melt_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_FETCH_ERROR, TALER_EC_MELT_DB_FETCH_ERROR,
"failed to fetch melt index"); NULL);
return qs; return qs;
} }
@ -367,7 +367,7 @@ melt_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_STORE_SESSION_ERROR, TALER_EC_MELT_DB_STORE_SESSION_ERROR,
"failed to persist melt data"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
return qs; return qs;
@ -417,7 +417,7 @@ handle_melt (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_MELT_COIN_SIGNATURE_INVALID, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_MELT_DB_FETCH_ERROR, TALER_EC_MELT_DB_FETCH_ERROR,
"failed to find information about old coin"); NULL);
} }
/* sanity check */ /* sanity check */
GNUNET_break (0 == GNUNET_break (0 ==
@ -549,7 +549,7 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
hc, hc,
ec, ec,
"unknown denomination"); NULL);
} }
TALER_amount_ntoh (&rmc->coin_refresh_fee, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_MELT_CURRENCY_MISMATCH, TALER_EC_MELT_CURRENCY_MISMATCH,
"value_with_fee"); rmc->refresh_session.amount_with_fee.
currency);
} }
/* check coin is actually properly signed */ /* 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_MELT_DENOMINATION_SIGNATURE_INVALID, TALER_EC_MELT_DENOMINATION_SIGNATURE_INVALID,
"denom_sig"); NULL);
} }
} }
TEH_KS_release (key_state); TEH_KS_release (key_state);
@ -593,7 +594,7 @@ check_for_denomination_key (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_MELT_FEES_EXCEED_CONTRIBUTION, TALER_EC_MELT_FEES_EXCEED_CONTRIBUTION,
"melt amount smaller than melting fee"); NULL);
} }
return handle_melt (connection, return handle_melt (connection,
rmc); rmc);

View File

@ -156,7 +156,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_FETCH_FAILED, TALER_EC_RECOUP_DB_FETCH_FAILED,
"failed to fetch old coin of blind coin"); NULL);
} }
return qs; return qs;
} }
@ -175,7 +175,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_FETCH_FAILED, TALER_EC_RECOUP_DB_FETCH_FAILED,
"failed to fetch reserve of blinded coin"); NULL);
} }
return qs; return qs;
} }
@ -188,7 +188,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_RECOUP_WITHDRAW_NOT_FOUND, TALER_EC_RECOUP_WITHDRAW_NOT_FOUND,
"envelope unknown"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
@ -206,7 +206,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_FETCH_FAILED, TALER_EC_RECOUP_DB_FETCH_FAILED,
"failed to fetch coin transaction history"); NULL);
} }
return qs; return qs;
} }
@ -241,7 +241,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_HISTORY_DB_ERROR, TALER_EC_RECOUP_HISTORY_DB_ERROR,
"failed to calculate old coin transaction history"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
GNUNET_log (GNUNET_ERROR_TYPE_INFO, GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@ -261,7 +261,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_COIN_BALANCE_NEGATIVE, TALER_EC_RECOUP_COIN_BALANCE_NEGATIVE,
"calculated negative coin balance"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
if ( (0 == pc->amount.fraction) && if ( (0 == pc->amount.fraction) &&
@ -328,7 +328,7 @@ recoup_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_DB_PUT_FAILED, TALER_EC_RECOUP_DB_PUT_FAILED,
"failed to persist recoup data"); NULL);
} }
return qs; return qs;
} }
@ -392,7 +392,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
hc, hc,
ec, ec,
"denomination not valid for recoup"); NULL);
} }
TALER_amount_ntoh (&pc.value, TALER_amount_ntoh (&pc.value,
&dki->issue.properties.value); &dki->issue.properties.value);
@ -407,7 +407,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_RECOUP_DENOMINATION_SIGNATURE_INVALID, TALER_EC_RECOUP_DENOMINATION_SIGNATURE_INVALID,
"denom_sig"); NULL);
} }
/* check recoup request signature */ /* check recoup request signature */
@ -431,7 +431,7 @@ verify_and_execute_recoup (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_RECOUP_SIGNATURE_INVALID, TALER_EC_RECOUP_SIGNATURE_INVALID,
"coin_sig"); NULL);
} }
} }
GNUNET_CRYPTO_hash (&coin->coin_pub.eddsa_pub, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RECOUP_BLINDING_FAILED, TALER_EC_RECOUP_BLINDING_FAILED,
"coin_bks"); NULL);
} }
TEH_KS_release (key_state); TEH_KS_release (key_state);
} }

View File

@ -257,7 +257,7 @@ refreshes_reveal_preflight (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_FETCH_REVEAL_ERROR, TALER_EC_REVEAL_DB_FETCH_REVEAL_ERROR,
"failed to fetch reveal data"); NULL);
rctx->preflight_ok = GNUNET_SYSERR; rctx->preflight_ok = GNUNET_SYSERR;
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_REVEAL_SESSION_UNKNOWN, TALER_EC_REVEAL_SESSION_UNKNOWN,
"rc"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
if (GNUNET_DB_STATUS_SOFT_ERROR == qs) 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR, TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR,
"failed to fetch valid challenge from database"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
@ -409,13 +409,14 @@ refreshes_reveal_transaction (void *cls,
&rc_expected)) &rc_expected))
{ {
GNUNET_break_op (0); GNUNET_break_op (0);
*mhd_ret = TALER_MHD_reply_json_pack (connection, *mhd_ret = TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o}", "{s:s, s:I, s:o}",
"hint", "commitment violation", "hint",
TALER_ErrorCode_get_hint (TALER_EC_REVEAL_COMMITMENT_VIOLATION),
"code", "code",
(json_int_t) (json_int_t) TALER_EC_REVEAL_COMMITMENT_VIOLATION,
TALER_EC_REVEAL_COMMITMENT_VIOLATION,
"rc_expected", "rc_expected",
GNUNET_JSON_from_data_auto ( GNUNET_JSON_from_data_auto (
&rc_expected)); &rc_expected));
@ -451,7 +452,7 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_COST_CALCULATION_OVERFLOW, TALER_EC_REVEAL_COST_CALCULATION_OVERFLOW,
"failed to add up refresh costs"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }
@ -462,7 +463,7 @@ refreshes_reveal_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_AMOUNT_INSUFFICIENT, TALER_EC_REVEAL_AMOUNT_INSUFFICIENT,
"melted coin value is insufficient to cover cost of operation"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }
@ -517,7 +518,7 @@ refreshes_reveal_persist (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_COMMIT_ERROR, TALER_EC_REVEAL_DB_COMMIT_ERROR,
"failed to persist reveal data"); NULL);
} }
return qs; return qs;
} }
@ -582,7 +583,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
hc, hc,
ec, ec,
"failed to find denomination key"); NULL);
} }
/* #TEH_KS_DKU_WITHDRAW should warrant that we only get denomination /* #TEH_KS_DKU_WITHDRAW should warrant that we only get denomination
keys where we did not yet forget the private key */ 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, ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_REVEAL_SESSION_UNKNOWN, TALER_EC_REVEAL_SESSION_UNKNOWN,
"rc"); NULL);
break; break;
case GNUNET_DB_STATUS_HARD_ERROR: case GNUNET_DB_STATUS_HARD_ERROR:
ret = TALER_MHD_reply_with_error (connection, ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR, TALER_EC_REVEAL_DB_FETCH_SESSION_ERROR,
"failed to fetch session data"); NULL);
break; break;
case GNUNET_DB_STATUS_SOFT_ERROR: case GNUNET_DB_STATUS_SOFT_ERROR:
default: default:
@ -644,7 +645,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection, ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_INTERNAL_INVARIANT_FAILURE, TALER_EC_INTERNAL_INVARIANT_FAILURE,
"assertion failed (unexpected database serialization error)"); NULL);
break; break;
} }
goto cleanup; goto cleanup;
@ -689,7 +690,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection, ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_REVEAL_LINK_SIGNATURE_INVALID, TALER_EC_REVEAL_LINK_SIGNATURE_INVALID,
"link_sig"); NULL);
goto cleanup; goto cleanup;
} }
} }
@ -716,7 +717,7 @@ resolve_refreshes_reveal_denominations (struct TEH_KS_StateHandle *key_state,
ret = TALER_MHD_reply_with_error (connection, ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REVEAL_SIGNING_ERROR, TALER_EC_REVEAL_SIGNING_ERROR,
"internal signing error"); NULL);
goto cleanup; goto cleanup;
} }
} }
@ -831,7 +832,7 @@ handle_refreshes_reveal_json (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_REVEAL_NEW_DENOMS_ARRAY_SIZE_EXCESSIVE, TALER_EC_REVEAL_NEW_DENOMS_ARRAY_SIZE_EXCESSIVE,
"new_denoms_h"); NULL);
} }
if (json_array_size (new_denoms_h_json) != 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_REVEAL_INVALID_RCH, TALER_EC_REVEAL_INVALID_RCH,
"refresh commitment hash malformed"); args[0]);
} }
if (0 != strcmp (args[1], if (0 != strcmp (args[1],
"reveal")) "reveal"))
@ -954,7 +955,7 @@ TEH_handler_reveal (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_OPERATION_INVALID, 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_REVEAL_CNC_TRANSFER_ARRAY_SIZE_INVALID, TALER_EC_REVEAL_CNC_TRANSFER_ARRAY_SIZE_INVALID,
"transfer_privs"); NULL);
} }
{ {

View File

@ -125,9 +125,9 @@ refund_transaction (void *cls,
{ {
if (GNUNET_DB_STATUS_HARD_ERROR == qs) if (GNUNET_DB_STATUS_HARD_ERROR == qs)
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REFUND_COIN_NOT_FOUND, TALER_EC_REFUND_DATABASE_LOOKUP_ERROR,
"database transaction failure"); NULL);
return qs; return qs;
} }
deposit_found = false; deposit_found = false;
@ -163,7 +163,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_GONE, MHD_HTTP_GONE,
TALER_EC_REFUND_MERCHANT_ALREADY_PAID, TALER_EC_REFUND_MERCHANT_ALREADY_PAID,
"money already sent to merchant"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
@ -230,9 +230,11 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_json_pack ( *mhd_ret = TALER_MHD_reply_json_pack (
connection, connection,
MHD_HTTP_PRECONDITION_FAILED, MHD_HTTP_PRECONDITION_FAILED,
"{s:s, s:I, s:o}", "{s:s, s:s, s:I, s:o}",
"hint", "detail",
"conflicting refund with different amount but same refund transaction ID", "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, "code", (json_int_t) TALER_EC_REFUND_INCONSISTENT_AMOUNT,
"history", TEH_RESPONSE_compile_transaction_history ( "history", TEH_RESPONSE_compile_transaction_history (
&refund->coin.coin_pub, &refund->coin.coin_pub,
@ -306,7 +308,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_REFUND_DEPOSIT_NOT_FOUND, TALER_EC_REFUND_DEPOSIT_NOT_FOUND,
"deposit unknown"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
@ -321,7 +323,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_REFUND_CURRENCY_MISMATCH, TALER_EC_REFUND_CURRENCY_MISMATCH,
"currencies involved do not match"); deposit_total.currency);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
@ -340,12 +342,15 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_json_pack ( *mhd_ret = TALER_MHD_reply_json_pack (
connection, connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o}", "{s:s, s:s, s:I, s:o}",
"hint", "detail",
"total amount refunded exceeds total amount deposited for this coin", "total amount refunded exceeds total amount deposited for this coin",
"code", (json_int_t) TALER_EC_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT, "hint",
"history", TEH_RESPONSE_compile_transaction_history ( TALER_ErrorCode_get_hint (TALER_EC_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT),
&refund->coin.coin_pub, "code",
(json_int_t) TALER_EC_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT,
"history",
TEH_RESPONSE_compile_transaction_history (&refund->coin.coin_pub,
tlx)); tlx));
TEH_plugin->free_coin_transaction_list (TEH_plugin->cls, TEH_plugin->free_coin_transaction_list (TEH_plugin->cls,
tlx); tlx);
@ -365,7 +370,7 @@ refund_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_REFUND_STORE_DB_ERROR, TALER_EC_REFUND_STORE_DB_ERROR,
"could not persist store information"); NULL);
return qs; return qs;
} }
/* Success or soft failure */ /* Success or soft failure */
@ -411,7 +416,7 @@ verify_and_execute_refund (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID, TALER_EC_REFUND_MERCHANT_SIGNATURE_INVALID,
"merchant_sig"); NULL);
} }
} }
@ -425,11 +430,18 @@ verify_and_execute_refund (struct MHD_Connection *connection,
&denom_hash); &denom_hash);
if (0 > qs) if (0 > qs)
{ {
MHD_RESULT res;
char *dhs;
GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs); GNUNET_break (GNUNET_DB_STATUS_HARD_ERROR == qs);
return TALER_MHD_reply_with_error (connection, dhs = GNUNET_STRINGS_data_to_string_alloc (&denom_hash,
sizeof (denom_hash));
res = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_REFUND_COIN_NOT_FOUND, TALER_EC_REFUND_COIN_NOT_FOUND,
"denomination of coin to be refunded not found in DB"); 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, return TALER_MHD_reply_with_error (connection,
hc, hc,
ec, ec,
"denomination not found, but coin known"); NULL);
} }
TALER_amount_ntoh (&refund->details.refund_fee, TALER_amount_ntoh (&refund->details.refund_fee,
&dki->issue.properties.fee_refund); &dki->issue.properties.fee_refund);

View File

@ -51,7 +51,7 @@ reply_reserve_history_success (struct MHD_Connection *connection,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_RESERVE_STATUS_DB_ERROR, TALER_EC_RESERVE_STATUS_DB_ERROR,
"balance calculation failure"); NULL);
json_balance = TALER_JSON_from_amount (&balance); json_balance = TALER_JSON_from_amount (&balance);
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK, MHD_HTTP_OK,
@ -143,7 +143,7 @@ TEH_handler_reserves_get (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_RESERVES_INVALID_RESERVE_PUB, TALER_EC_RESERVES_INVALID_RESERVE_PUB,
"reserve public key malformed"); args[0]);
} }
rsc.rh = NULL; rsc.rh = NULL;
if (GNUNET_OK != if (GNUNET_OK !=
@ -156,14 +156,10 @@ TEH_handler_reserves_get (const struct TEH_RequestHandler *rh,
/* generate proper response */ /* generate proper response */
if (NULL == rsc.rh) if (NULL == rsc.rh)
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
"{s:s, s:s, s:I}", TALER_EC_RESERVE_STATUS_UNKNOWN,
"hint", "Reserve not found", args[0]);
"parameter", "reserve_pub",
"code",
(json_int_t)
TALER_EC_RESERVE_STATUS_UNKNOWN);
mhd_ret = reply_reserve_history_success (connection, mhd_ret = reply_reserve_history_success (connection,
rsc.rh); rsc.rh);
TEH_plugin->free_reserve_history (TEH_plugin->cls, TEH_plugin->free_reserve_history (TEH_plugin->cls,

View File

@ -445,13 +445,13 @@ TEH_RESPONSE_reply_coin_insufficient_funds (
GNUNET_break (0); GNUNET_break (0);
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_COIN_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, TALER_EC_JSON_ALLOCATION_FAILURE,
"failed to convert transaction history to JSON"); "Failed to generated proof of insufficient funds");
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o}", "{s:s, s:I, s:o}",
"hint", "insufficient funds", "hint", TALER_ErrorCode_get_hint (ec),
"code", (json_int_t) ec, "code", (json_int_t) ec,
"history", history); "history", history);
} }

View File

@ -446,7 +446,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_DB_FETCH_FAILED, TALER_EC_TRANSFERS_GET_DB_FETCH_FAILED,
"failed to fetch transaction data"); NULL);
} }
return qs; return qs;
} }
@ -456,7 +456,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_DB_INCONSISTENT, TALER_EC_TRANSFERS_GET_DB_INCONSISTENT,
"exchange database internally inconsistent"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
if (GNUNET_NO == ctx->is_valid) if (GNUNET_NO == ctx->is_valid)
@ -464,7 +464,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_TRANSFERS_GET_WTID_NOT_FOUND, TALER_EC_TRANSFERS_GET_WTID_NOT_FOUND,
"wtid"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
qs = TEH_plugin->get_wire_fee (TEH_plugin->cls, 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_WIRE_FEE_NOT_FOUND, TALER_EC_TRANSFERS_GET_WIRE_FEE_NOT_FOUND,
"did not find wire fee"); NULL);
} }
return qs; return qs;
} }
@ -498,7 +498,7 @@ get_transfer_deposits (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_TRANSFERS_GET_WIRE_FEE_INCONSISTENT, TALER_EC_TRANSFERS_GET_WIRE_FEE_INCONSISTENT,
"could not subtract wire fee"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
return GNUNET_DB_STATUS_SUCCESS_ONE_RESULT; 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_TRANSFERS_INVALID_WTID, TALER_EC_TRANSFERS_INVALID_WTID,
"wire transfer identifier malformed"); args[0]);
} }
if (GNUNET_OK != if (GNUNET_OK !=
TEH_DB_run_transaction (connection, TEH_DB_run_transaction (connection,

View File

@ -66,7 +66,7 @@ reply_withdraw_insufficient_funds (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS, TALER_EC_WITHDRAW_HISTORY_DB_ERROR_INSUFFICIENT_FUNDS,
"reserve balance calculation failure"); NULL);
if (0 != if (0 !=
TALER_amount_cmp (&balance, TALER_amount_cmp (&balance,
ebalance)) ebalance))
@ -76,18 +76,20 @@ reply_withdraw_insufficient_funds (
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_RESERVE_BALANCE_CORRUPT, TALER_EC_WITHDRAW_RESERVE_BALANCE_CORRUPT,
"internal balance inconsistency error"); NULL);
} }
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_CONFLICT, MHD_HTTP_CONFLICT,
"{s:s, s:I, s:o, s:o}", "{s:s, s:I, s:o, s:o}",
"hint", "insufficient funds", "hint",
TALER_ErrorCode_get_hint (TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS),
"code", "code",
(json_int_t) (json_int_t) TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS,
TALER_EC_WITHDRAW_INSUFFICIENT_FUNDS, "balance",
"balance", TALER_JSON_from_amount ( TALER_JSON_from_amount (&balance),
&balance), "history",
"history", json_history); json_history);
} }
@ -197,7 +199,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_FETCH_ERROR, TALER_EC_WITHDRAW_DB_FETCH_ERROR,
"failed to fetch withdraw data"); NULL);
wc->collectable.sig = denom_sig; wc->collectable.sig = denom_sig;
return qs; return qs;
} }
@ -232,7 +234,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_FETCH_ERROR, TALER_EC_WITHDRAW_DB_FETCH_ERROR,
"failed to fetch reserve data"); NULL);
return qs; return qs;
} }
if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_FOUND,
TALER_EC_WITHDRAW_RESERVE_UNKNOWN, TALER_EC_WITHDRAW_RESERVE_UNKNOWN,
"reserve_pub"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
if (0 < TALER_amount_cmp (&wc->amount_required, 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_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_FETCH_ERROR, TALER_EC_WITHDRAW_DB_FETCH_ERROR,
"failed to fetch reserve history"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
*mhd_ret = reply_withdraw_insufficient_funds (connection, *mhd_ret = reply_withdraw_insufficient_funds (connection,
@ -299,7 +301,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_SIGNATURE_FAILED, TALER_EC_WITHDRAW_SIGNATURE_FAILED,
"Failed to create blind signature"); NULL);
return GNUNET_DB_STATUS_HARD_ERROR; return GNUNET_DB_STATUS_HARD_ERROR;
} }
} }
@ -319,7 +321,7 @@ withdraw_transaction (void *cls,
*mhd_ret = TALER_MHD_reply_with_error (connection, *mhd_ret = TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_DB_STORE_ERROR, TALER_EC_WITHDRAW_DB_STORE_ERROR,
"failed to persist withdraw data"); NULL);
return qs; return qs;
} }
return qs; return qs;
@ -370,7 +372,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_RESERVES_INVALID_RESERVE_PUB, 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, return TALER_MHD_reply_with_error (connection,
hc, hc,
ec, ec,
"could not find denomination key"); NULL);
} }
} }
GNUNET_assert (NULL != wc.dki->denom_priv.rsa_private_key); 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, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW, TALER_EC_WITHDRAW_AMOUNT_FEE_OVERFLOW,
"amount overflow for value plus withdraw fee"); NULL);
} }
TALER_amount_hton (&wc.wsrd.amount_with_fee, TALER_amount_hton (&wc.wsrd.amount_with_fee,
&wc.amount_required); &wc.amount_required);
@ -459,7 +461,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_FORBIDDEN, MHD_HTTP_FORBIDDEN,
TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID, TALER_EC_WITHDRAW_RESERVE_SIGNATURE_INVALID,
"reserve_sig"); NULL);
} }
#if OPTIMISTIC_SIGN #if OPTIMISTIC_SIGN
@ -476,7 +478,7 @@ TEH_handler_withdraw (const struct TEH_RequestHandler *rh,
return TALER_MHD_reply_with_error (connection, return TALER_MHD_reply_with_error (connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_WITHDRAW_SIGNATURE_FAILED, TALER_EC_WITHDRAW_SIGNATURE_FAILED,
"Failed to sign"); NULL);
} }
#endif #endif

View File

@ -133,14 +133,14 @@ TALER_MHD_reply_json_pack (struct MHD_Connection *connection,
* @param connection the MHD connection to use * @param connection the MHD connection to use
* @param ec error code uniquely identifying the error * @param ec error code uniquely identifying the error
* @param http_status HTTP status code to use * @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 * @return a MHD result code
*/ */
MHD_RESULT MHD_RESULT
TALER_MHD_reply_with_error (struct MHD_Connection *connection, TALER_MHD_reply_with_error (struct MHD_Connection *connection,
unsigned int http_status, unsigned int http_status,
enum TALER_ErrorCode ec, 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. * Create a response indicating an internal error.
* *
* @param ec error code to return * @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 * @return a MHD response object
*/ */
struct MHD_Response * struct MHD_Response *
TALER_MHD_make_error (enum TALER_ErrorCode ec, TALER_MHD_make_error (enum TALER_ErrorCode ec,
const char *hint); const char *detail);
/** /**

View File

@ -651,7 +651,8 @@ TALER_JSON_get_error_hint (const json_t *json)
GNUNET_break_op (0); GNUNET_break_op (0);
return NULL; return NULL;
} }
jc = json_object_get (json, "hint"); jc = json_object_get (json,
"hint");
if (NULL == jc) if (NULL == jc)
return NULL; /* no hint, is allowed */ return NULL; /* no hint, is allowed */
if (! json_is_string (jc)) if (! json_is_string (jc))

View File

@ -24,6 +24,7 @@
#include <gnunet/gnunet_json_lib.h> #include <gnunet/gnunet_json_lib.h>
#include <jansson.h> #include <jansson.h>
#include <microhttpd.h> #include <microhttpd.h>
#include "taler_util.h"
#include "taler_mhd_lib.h" #include "taler_mhd_lib.h"

View File

@ -76,11 +76,11 @@ TALER_MHD_parse_post_json (struct MHD_Connection *connection,
case GNUNET_JSON_PR_OUT_OF_MEMORY: case GNUNET_JSON_PR_OUT_OF_MEMORY:
GNUNET_break (NULL == *json); GNUNET_break (NULL == *json);
return (MHD_NO == return (MHD_NO ==
TALER_MHD_reply_with_error TALER_MHD_reply_with_error (
(connection, connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_PARSER_OUT_OF_MEMORY, TALER_EC_PARSER_OUT_OF_MEMORY,
"out of memory")) ? GNUNET_SYSERR : GNUNET_NO; NULL)) ? GNUNET_SYSERR : GNUNET_NO;
case GNUNET_JSON_PR_CONTINUE: case GNUNET_JSON_PR_CONTINUE:
GNUNET_break (NULL == *json); GNUNET_break (NULL == *json);
@ -96,7 +96,7 @@ TALER_MHD_parse_post_json (struct MHD_Connection *connection,
TALER_MHD_reply_with_error (connection, TALER_MHD_reply_with_error (connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
TALER_EC_JSON_INVALID, TALER_EC_JSON_INVALID,
"invalid JSON uploaded")) NULL))
? GNUNET_NO : GNUNET_SYSERR; ? GNUNET_NO : GNUNET_SYSERR;
case GNUNET_JSON_PR_SUCCESS: case GNUNET_JSON_PR_SUCCESS:
GNUNET_break (NULL != *json); GNUNET_break (NULL != *json);
@ -204,13 +204,13 @@ TALER_MHD_parse_json_data (struct MHD_Connection *connection,
if (NULL == error_json_name) if (NULL == error_json_name)
error_json_name = "<no field>"; error_json_name = "<no field>";
ret = (MHD_YES == ret = (MHD_YES ==
TALER_MHD_reply_json_pack (connection, TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
"{s:s, s:I, s:s, s:I}", "{s:s, s:I, s:s, s:I}",
"hint", "JSON parse error", "hint", TALER_ErrorCode_get_hint (
"code", TALER_EC_JSON_INVALID_WITH_DETAILS),
(json_int_t) "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS,
TALER_EC_JSON_INVALID_WITH_DETAILS,
"field", error_json_name, "field", error_json_name,
"line", (json_int_t) error_line)) "line", (json_int_t) error_line))
? GNUNET_NO : GNUNET_SYSERR; ? GNUNET_NO : GNUNET_SYSERR;
@ -256,13 +256,13 @@ TALER_MHD_parse_internal_json_data (struct MHD_Connection *connection,
if (NULL == error_json_name) if (NULL == error_json_name)
error_json_name = "<no field>"; error_json_name = "<no field>";
ret = (MHD_YES == ret = (MHD_YES ==
TALER_MHD_reply_json_pack (connection, TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_INTERNAL_SERVER_ERROR,
"{s:s, s:I, s:s, s:I}", "{s:s, s:I, s:s, s:I}",
"hint", "JSON parse error", "hint", TALER_ErrorCode_get_hint (
"code", TALER_EC_INTERNAL_INVARIANT_FAILURE),
(json_int_t) "code", (json_int_t) TALER_EC_INTERNAL_INVARIANT_FAILURE,
TALER_EC_INTERNAL_INVARIANT_FAILURE,
"field", error_json_name, "field", error_json_name,
"line", (json_int_t) error_line)) "line", (json_int_t) error_line))
? GNUNET_NO : GNUNET_SYSERR; ? GNUNET_NO : GNUNET_SYSERR;
@ -311,13 +311,14 @@ TALER_MHD_parse_json_array (struct MHD_Connection *connection,
if (NULL == root) if (NULL == root)
{ {
ret = (MHD_YES == ret = (MHD_YES ==
TALER_MHD_reply_json_pack (connection, TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
"{s:s, s:I, s:I}", "{s:s, s:I, s:s, s:I}",
"hint", "expected array", "hint", TALER_ErrorCode_get_hint (
"code", TALER_EC_JSON_INVALID_WITH_DETAILS),
(json_int_t) "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS,
TALER_EC_JSON_INVALID_WITH_DETAILS, "detail", "expected array",
"dimension", dim)) "dimension", dim))
? GNUNET_NO : GNUNET_SYSERR; ? GNUNET_NO : GNUNET_SYSERR;
return ret; return ret;
@ -331,13 +332,14 @@ TALER_MHD_parse_json_array (struct MHD_Connection *connection,
if (NULL == error_json_name) if (NULL == error_json_name)
error_json_name = "<no field>"; error_json_name = "<no field>";
ret = (MHD_YES == ret = (MHD_YES ==
TALER_MHD_reply_json_pack (connection, TALER_MHD_reply_json_pack (
connection,
MHD_HTTP_BAD_REQUEST, MHD_HTTP_BAD_REQUEST,
"{s:s, s:I, s:I}", "{s:s, s:s, s:I, s:I}",
"hint", error_json_name, "detail", error_json_name,
"code", "hint", TALER_ErrorCode_get_hint (
(json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS),
TALER_EC_JSON_INVALID_WITH_DETAILS, "code", (json_int_t) TALER_EC_JSON_INVALID_WITH_DETAILS,
"line", (json_int_t) error_line)) "line", (json_int_t) error_line))
? GNUNET_NO : GNUNET_SYSERR; ? GNUNET_NO : GNUNET_SYSERR;
return ret; return ret;

View File

@ -404,16 +404,17 @@ TALER_MHD_make_json_pack (const char *fmt,
* Create a response indicating an internal error. * Create a response indicating an internal error.
* *
* @param ec error code to return * @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 * @return a MHD response object
*/ */
struct MHD_Response * struct MHD_Response *
TALER_MHD_make_error (enum TALER_ErrorCode ec, 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, "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 connection the MHD connection to use
* @param ec error code uniquely identifying the error * @param ec error code uniquely identifying the error
* @param http_status HTTP status code to use * @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 * @return a MHD result code
*/ */
MHD_RESULT MHD_RESULT
TALER_MHD_reply_with_error (struct MHD_Connection *connection, TALER_MHD_reply_with_error (struct MHD_Connection *connection,
unsigned int http_status, unsigned int http_status,
enum TALER_ErrorCode ec, enum TALER_ErrorCode ec,
const char *hint) const char *detail)
{ {
return TALER_MHD_reply_json_pack (connection, return TALER_MHD_reply_json_pack (connection,
http_status, http_status,
"{s:I, s:s}", "{s:I, s:s, s:s?}",
"code", (json_int_t) ec, "code", (json_int_t) ec,
"hint", hint); "hint", TALER_ErrorCode_get_hint (ec),
"detail", detail);
} }