remove duplicated, wrong ec logic in bank-lib
This commit is contained in:
parent
1032cdea0f
commit
3d9ad86dfb
@ -112,27 +112,27 @@ handle_admin_add_incoming_finished (void *cls,
|
|||||||
case MHD_HTTP_BAD_REQUEST:
|
case MHD_HTTP_BAD_REQUEST:
|
||||||
/* This should never happen, either us or the bank is buggy
|
/* This should never happen, either us or the bank is buggy
|
||||||
(or API version conflict); just pass JSON reply to the application */
|
(or API version conflict); just pass JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_FORBIDDEN:
|
case MHD_HTTP_FORBIDDEN:
|
||||||
/* Access denied */
|
/* Access denied */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_UNAUTHORIZED:
|
case MHD_HTTP_UNAUTHORIZED:
|
||||||
/* Nothing really to verify, bank says one of the signatures is
|
/* Nothing really to verify, bank says one of the signatures is
|
||||||
invalid; as we checked them, this should never happen, we
|
invalid; as we checked them, this should never happen, we
|
||||||
should pass the JSON reply to the application */
|
should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_NOT_FOUND:
|
case MHD_HTTP_NOT_FOUND:
|
||||||
/* Nothing really to verify, this should never
|
/* Nothing really to verify, this should never
|
||||||
happen, we should pass the JSON reply to the application */
|
happen, we should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
||||||
/* Server had an internal issue; we should retry, but this API
|
/* Server had an internal issue; we should retry, but this API
|
||||||
leaves this to the application */
|
leaves this to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* unexpected response code */
|
/* unexpected response code */
|
||||||
@ -140,7 +140,7 @@ handle_admin_add_incoming_finished (void *cls,
|
|||||||
"Unexpected response code %u\n",
|
"Unexpected response code %u\n",
|
||||||
(unsigned int) response_code);
|
(unsigned int) response_code);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
response_code = 0;
|
response_code = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -97,34 +97,4 @@ TALER_BANK_path_to_url_ (const char *u,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse error code given in @a json.
|
|
||||||
*
|
|
||||||
* @param json the json to parse.
|
|
||||||
*
|
|
||||||
* @return error code, or #TALER_EC_INVALID if not found.
|
|
||||||
*/
|
|
||||||
enum TALER_ErrorCode
|
|
||||||
TALER_BANK_parse_ec_ (const json_t *json)
|
|
||||||
{
|
|
||||||
uint32_t ec;
|
|
||||||
|
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
|
||||||
GNUNET_JSON_spec_uint32 ("ec",
|
|
||||||
&ec),
|
|
||||||
GNUNET_JSON_spec_end ()
|
|
||||||
};
|
|
||||||
|
|
||||||
if (GNUNET_OK !=
|
|
||||||
GNUNET_JSON_parse (json,
|
|
||||||
spec,
|
|
||||||
NULL, NULL))
|
|
||||||
{
|
|
||||||
GNUNET_break_op (0);
|
|
||||||
return TALER_EC_INVALID;
|
|
||||||
}
|
|
||||||
return (enum TALER_ErrorCode) ec;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* end of bank_api_common.c */
|
/* end of bank_api_common.c */
|
||||||
|
@ -63,14 +63,4 @@ TALER_BANK_path_to_url_ (const char *u,
|
|||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse error code given in @a json.
|
|
||||||
*
|
|
||||||
* @param json the json to parse
|
|
||||||
* @return error code, or #TALER_EC_INVALID if not found
|
|
||||||
*/
|
|
||||||
enum TALER_ErrorCode
|
|
||||||
TALER_BANK_parse_ec_ (const json_t *json);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -172,27 +172,27 @@ handle_history_finished (void *cls,
|
|||||||
case MHD_HTTP_BAD_REQUEST:
|
case MHD_HTTP_BAD_REQUEST:
|
||||||
/* This should never happen, either us or the bank is buggy
|
/* This should never happen, either us or the bank is buggy
|
||||||
(or API version conflict); just pass JSON reply to the application */
|
(or API version conflict); just pass JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_FORBIDDEN:
|
case MHD_HTTP_FORBIDDEN:
|
||||||
/* Access denied */
|
/* Access denied */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_UNAUTHORIZED:
|
case MHD_HTTP_UNAUTHORIZED:
|
||||||
/* Nothing really to verify, bank says one of the signatures is
|
/* Nothing really to verify, bank says one of the signatures is
|
||||||
invalid; as we checked them, this should never happen, we
|
invalid; as we checked them, this should never happen, we
|
||||||
should pass the JSON reply to the application */
|
should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_NOT_FOUND:
|
case MHD_HTTP_NOT_FOUND:
|
||||||
/* Nothing really to verify, this should never
|
/* Nothing really to verify, this should never
|
||||||
happen, we should pass the JSON reply to the application */
|
happen, we should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
||||||
/* Server had an internal issue; we should retry, but this API
|
/* Server had an internal issue; we should retry, but this API
|
||||||
leaves this to the application */
|
leaves this to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* unexpected response code */
|
/* unexpected response code */
|
||||||
@ -200,7 +200,7 @@ handle_history_finished (void *cls,
|
|||||||
"Unexpected response code %u\n",
|
"Unexpected response code %u\n",
|
||||||
(unsigned int) response_code);
|
(unsigned int) response_code);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
response_code = 0;
|
response_code = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -169,27 +169,27 @@ handle_history_finished (void *cls,
|
|||||||
case MHD_HTTP_BAD_REQUEST:
|
case MHD_HTTP_BAD_REQUEST:
|
||||||
/* This should never happen, either us or the bank is buggy
|
/* This should never happen, either us or the bank is buggy
|
||||||
(or API version conflict); just pass JSON reply to the application */
|
(or API version conflict); just pass JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_FORBIDDEN:
|
case MHD_HTTP_FORBIDDEN:
|
||||||
/* Access denied */
|
/* Access denied */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_UNAUTHORIZED:
|
case MHD_HTTP_UNAUTHORIZED:
|
||||||
/* Nothing really to verify, bank says one of the signatures is
|
/* Nothing really to verify, bank says one of the signatures is
|
||||||
invalid; as we checked them, this should never happen, we
|
invalid; as we checked them, this should never happen, we
|
||||||
should pass the JSON reply to the application */
|
should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_NOT_FOUND:
|
case MHD_HTTP_NOT_FOUND:
|
||||||
/* Nothing really to verify, this should never
|
/* Nothing really to verify, this should never
|
||||||
happen, we should pass the JSON reply to the application */
|
happen, we should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
||||||
/* Server had an internal issue; we should retry, but this API
|
/* Server had an internal issue; we should retry, but this API
|
||||||
leaves this to the application */
|
leaves this to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* unexpected response code */
|
/* unexpected response code */
|
||||||
@ -197,7 +197,7 @@ handle_history_finished (void *cls,
|
|||||||
"Unexpected response code %u\n",
|
"Unexpected response code %u\n",
|
||||||
(unsigned int) response_code);
|
(unsigned int) response_code);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
response_code = 0;
|
response_code = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -196,27 +196,27 @@ handle_transfer_finished (void *cls,
|
|||||||
case MHD_HTTP_BAD_REQUEST:
|
case MHD_HTTP_BAD_REQUEST:
|
||||||
/* This should never happen, either us or the bank is buggy
|
/* This should never happen, either us or the bank is buggy
|
||||||
(or API version conflict); just pass JSON reply to the application */
|
(or API version conflict); just pass JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_FORBIDDEN:
|
case MHD_HTTP_FORBIDDEN:
|
||||||
/* Access denied */
|
/* Access denied */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_UNAUTHORIZED:
|
case MHD_HTTP_UNAUTHORIZED:
|
||||||
/* Nothing really to verify, bank says one of the signatures is
|
/* Nothing really to verify, bank says one of the signatures is
|
||||||
invalid; as we checked them, this should never happen, we
|
invalid; as we checked them, this should never happen, we
|
||||||
should pass the JSON reply to the application */
|
should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_NOT_FOUND:
|
case MHD_HTTP_NOT_FOUND:
|
||||||
/* Nothing really to verify, this should never
|
/* Nothing really to verify, this should never
|
||||||
happen, we should pass the JSON reply to the application */
|
happen, we should pass the JSON reply to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
case MHD_HTTP_INTERNAL_SERVER_ERROR:
|
||||||
/* Server had an internal issue; we should retry, but this API
|
/* Server had an internal issue; we should retry, but this API
|
||||||
leaves this to the application */
|
leaves this to the application */
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* unexpected response code */
|
/* unexpected response code */
|
||||||
@ -224,7 +224,7 @@ handle_transfer_finished (void *cls,
|
|||||||
"Unexpected response code %u\n",
|
"Unexpected response code %u\n",
|
||||||
(unsigned int) response_code);
|
(unsigned int) response_code);
|
||||||
GNUNET_break (0);
|
GNUNET_break (0);
|
||||||
ec = TALER_BANK_parse_ec_ (j);
|
ec = TALER_JSON_get_error_code (j);
|
||||||
response_code = 0;
|
response_code = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user