exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit e1431c7a82daa19b2cbfb95b5851f186fd65ceb8
parent de965ce14a88dcc196a43a96123abd1d9c0e2915
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  7 Apr 2026 11:18:25 +0200

handle NOT_ACCEPTABLE more nicely

Diffstat:
Msrc/exchange/taler-exchange-httpd_get-aml-OFFICER_PUB-attributes-H_NORMALIZED_PAYTO.c | 6+++---
Msrc/include/taler/taler_error_codes.h | 32++++++++++++++++++++++++++++++++
Msrc/lib/exchange_api_get-aml-OFFICER_PUB-attributes-H_NORMALIZED_PAYTO.c | 4++++
Msrc/util/taler_error_codes.c | 34+++++++++++++++++++++++++++++++++-
4 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd_get-aml-OFFICER_PUB-attributes-H_NORMALIZED_PAYTO.c b/src/exchange/taler-exchange-httpd_get-aml-OFFICER_PUB-attributes-H_NORMALIZED_PAYTO.c @@ -708,11 +708,11 @@ TEH_handler_aml_attributes_get ( else { GNUNET_break_op (0); - return TALER_MHD_REPLY_JSON_PACK ( + return TALER_MHD_reply_with_error ( rc->connection, MHD_HTTP_NOT_ACCEPTABLE, - GNUNET_JSON_pack_string ("hint", - mime)); + TALER_EC_GENERIC_REQUESTED_FORMAT_UNSUPPORTED, + mime); } } diff --git a/src/include/taler/taler_error_codes.h b/src/include/taler/taler_error_codes.h @@ -431,6 +431,14 @@ enum TALER_ErrorCode /** + * The requested content type is not supported by the server. The client should try requesting a different format. + * Returned with an HTTP status code of #MHD_HTTP_NOT_ACCEPTABLE (406). + * (A value of 0 indicates that the error is generated client-side). + */ + TALER_EC_GENERIC_REQUESTED_FORMAT_UNSUPPORTED = 78, + + + /** * Exchange is badly configured and thus cannot operate. * Returned with an HTTP status code of #MHD_HTTP_INTERNAL_SERVER_ERROR (500). * (A value of 0 indicates that the error is generated client-side). @@ -832,6 +840,14 @@ enum TALER_ErrorCode /** + * The specified AML officer does not have write access at this time. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_READ_ONLY = 1050, + + + /** * The exchange did not find information about the specified transaction in the database. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). * (A value of 0 indicates that the error is generated client-side). @@ -4529,6 +4545,22 @@ enum TALER_ErrorCode /** + * The authorization_pub for a request to transfer funds has already been used for another non recurrent transfer. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + TALER_EC_BANK_TRANSFER_MAPPING_REUSED = 5162, + + + /** + * The authorization_pub for a request to transfer funds is not currently registered. + * Returned with an HTTP status code of #MHD_HTTP_CONFLICT (409). + * (A value of 0 indicates that the error is generated client-side). + */ + TALER_EC_BANK_TRANSFER_MAPPING_UNKNOWN = 5163, + + + /** * The sync service failed find the account in its database. * Returned with an HTTP status code of #MHD_HTTP_NOT_FOUND (404). * (A value of 0 indicates that the error is generated client-side). diff --git a/src/lib/exchange_api_get-aml-OFFICER_PUB-attributes-H_NORMALIZED_PAYTO.c b/src/lib/exchange_api_get-aml-OFFICER_PUB-attributes-H_NORMALIZED_PAYTO.c @@ -269,6 +269,10 @@ handle_get_aml_attributes_finished (void *cls, lr.hr.ec = TALER_JSON_get_error_code (j); lr.hr.hint = TALER_JSON_get_error_hint (j); break; + case MHD_HTTP_NOT_ACCEPTABLE: + lr.hr.ec = TALER_JSON_get_error_code (j); + lr.hr.hint = TALER_JSON_get_error_hint (j); + break; case MHD_HTTP_INTERNAL_SERVER_ERROR: lr.hr.ec = TALER_JSON_get_error_code (j); lr.hr.hint = TALER_JSON_get_error_hint (j); diff --git a/src/util/taler_error_codes.c b/src/util/taler_error_codes.c @@ -441,6 +441,14 @@ static const struct ErrorCodeAndHint code_hint_pairs[] = { }, { + /* 78 */ + .ec = TALER_EC_GENERIC_REQUESTED_FORMAT_UNSUPPORTED, + .hint = gettext_noop ( + "The requested content type is not supported by the server. The client should try requesting a different format."), + .http_code = MHD_HTTP_NOT_ACCEPTABLE + }, + + { /* 1000 */ .ec = TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION, .hint = gettext_noop ( @@ -835,6 +843,14 @@ static const struct ErrorCodeAndHint code_hint_pairs[] = { }, { + /* 1050 */ + .ec = TALER_EC_EXCHANGE_GENERIC_AML_OFFICER_READ_ONLY, + .hint = gettext_noop ( + "The specified AML officer does not have write access at this time."), + .http_code = MHD_HTTP_CONFLICT + }, + + { /* 1100 */ .ec = TALER_EC_EXCHANGE_DEPOSITS_GET_NOT_FOUND, .hint = gettext_noop ( @@ -4485,6 +4501,22 @@ static const struct ErrorCodeAndHint code_hint_pairs[] = { }, { + /* 5162 */ + .ec = TALER_EC_BANK_TRANSFER_MAPPING_REUSED, + .hint = gettext_noop ( + "The authorization_pub for a request to transfer funds has already been used for another non recurrent transfer."), + .http_code = MHD_HTTP_CONFLICT + }, + + { + /* 5163 */ + .ec = TALER_EC_BANK_TRANSFER_MAPPING_UNKNOWN, + .hint = gettext_noop ( + "The authorization_pub for a request to transfer funds is not currently registered."), + .http_code = MHD_HTTP_CONFLICT + }, + + { /* 6100 */ .ec = TALER_EC_SYNC_ACCOUNT_UNKNOWN, .hint = gettext_noop ( @@ -5743,7 +5775,7 @@ static const struct ErrorCodeAndHint code_hint_pairs[] = { /** * The length of @e code_hint_pairs. */ -static const unsigned int code_hint_pairs_length = 719; +static const unsigned int code_hint_pairs_length = 723; const char *