in Source/Shared/public_utils_legacy.cpp [13:94]
xbl_error_code ConvertHrToXblErrorCode(HRESULT hr)
{
switch (hr)
{
case S_OK: return xbl_error_code::no_error;
case E_OUTOFMEMORY: return xbl_error_code::bad_alloc;
case E_INVALIDARG: return xbl_error_code::invalid_argument;
case E_XBL_RUNTIME_ERROR: return xbl_error_code::runtime_error;
case __HRESULT_FROM_WIN32(ERROR_BAD_LENGTH): return xbl_error_code::length_error;
case E_BOUNDS: return xbl_error_code::out_of_range;
case E_NOINTERFACE: return xbl_error_code::bad_cast;
case E_UNEXPECTED: return xbl_error_code::logic_error;
case WEB_E_INVALID_JSON_STRING: return xbl_error_code::json_error;
case WEB_E_UNEXPECTED_CONTENT: return xbl_error_code::uri_error;
case ONL_E_ACTION_REQUIRED: return xbl_error_code::auth_user_interaction_required;
case E_XBL_RTA_GENERIC_ERROR: return xbl_error_code::rta_generic_error;
case E_XBL_RTA_SUBSCRIPTION_LIMIT_REACHED: return xbl_error_code::rta_subscription_limit_reached;
case E_XBL_RTA_ACCESS_DENIED: return xbl_error_code::rta_access_denied;
case E_XBL_RTA_NOT_ACTIVATED: return xbl_error_code::rta_not_activated;
case E_XBL_AUTH_UNKNOWN_ERROR: return xbl_error_code::auth_unknown_error;
case E_XBL_AUTH_RUNTIME_ERROR: return xbl_error_code::auth_runtime_error;
case E_XBL_AUTH_NO_TOKEN: return xbl_error_code::auth_no_token_error;
case __HRESULT_FROM_WIN32(ERROR_NO_SUCH_USER): return xbl_error_code::auth_user_not_signed_in;
case __HRESULT_FROM_WIN32(ERROR_CANCELLED): return xbl_error_code::auth_user_cancel;
case __HRESULT_FROM_WIN32(ERROR_BAD_CONFIGURATION): return xbl_error_code::invalid_config;
case E_NOTIMPL: return xbl_error_code::unsupported;
// HTTP errors
case __HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND): return xbl_error_code::http_status_204_resource_data_not_found;
case HTTP_E_STATUS_AMBIGUOUS: return xbl_error_code::http_status_300_multiple_choices;
case HTTP_E_STATUS_MOVED: return xbl_error_code::http_status_301_moved_permanently;
case HTTP_E_STATUS_REDIRECT: return xbl_error_code::http_status_302_found;
case HTTP_E_STATUS_REDIRECT_METHOD: return xbl_error_code::http_status_303_see_other;
case HTTP_E_STATUS_NOT_MODIFIED: return xbl_error_code::http_status_304_not_modified;
case HTTP_E_STATUS_USE_PROXY: return xbl_error_code::http_status_305_use_proxy;
case HTTP_E_STATUS_REDIRECT_KEEP_VERB: return xbl_error_code::http_status_307_temporary_redirect;
case HTTP_E_STATUS_BAD_REQUEST: return xbl_error_code::http_status_400_bad_request;
case HTTP_E_STATUS_DENIED: return xbl_error_code::http_status_401_unauthorized;
case HTTP_E_STATUS_PAYMENT_REQ: return xbl_error_code::http_status_402_payment_required;
case HTTP_E_STATUS_FORBIDDEN: return xbl_error_code::http_status_403_forbidden;
case HTTP_E_STATUS_NOT_FOUND: return xbl_error_code::http_status_404_not_found;
case HTTP_E_STATUS_BAD_METHOD: return xbl_error_code::http_status_405_method_not_allowed;
case HTTP_E_STATUS_NONE_ACCEPTABLE: return xbl_error_code::http_status_406_not_acceptable;
case HTTP_E_STATUS_PROXY_AUTH_REQ: return xbl_error_code::http_status_407_proxy_authentication_required;
case HTTP_E_STATUS_REQUEST_TIMEOUT: return xbl_error_code::http_status_408_request_timeout;
case HTTP_E_STATUS_CONFLICT: return xbl_error_code::http_status_409_conflict;
case HTTP_E_STATUS_GONE: return xbl_error_code::http_status_410_gone;
case HTTP_E_STATUS_LENGTH_REQUIRED: return xbl_error_code::http_status_411_length_required;
case HTTP_E_STATUS_PRECOND_FAILED: return xbl_error_code::http_status_412_precondition_failed;
case HTTP_E_STATUS_REQUEST_TOO_LARGE: return xbl_error_code::http_status_413_request_entity_too_large;
case HTTP_E_STATUS_URI_TOO_LONG: return xbl_error_code::http_status_414_request_uri_too_long;
case HTTP_E_STATUS_UNSUPPORTED_MEDIA: return xbl_error_code::http_status_415_unsupported_media_type;
case HTTP_E_STATUS_RANGE_NOT_SATISFIABLE: return xbl_error_code::http_status_416_requested_range_not_satisfiable;
case HTTP_E_STATUS_EXPECTATION_FAILED: return xbl_error_code::http_status_417_expectation_failed;
case MAKE_HTTP_HRESULT(421): return xbl_error_code::http_status_421_misdirected_request;
case MAKE_HTTP_HRESULT(422): return xbl_error_code::http_status_422_unprocessable_entity;
case MAKE_HTTP_HRESULT(423): return xbl_error_code::http_status_423_locked;
case MAKE_HTTP_HRESULT(424): return xbl_error_code::http_status_424_failed_dependency;
case MAKE_HTTP_HRESULT(426): return xbl_error_code::http_status_426_upgrade_required;
case MAKE_HTTP_HRESULT(428): return xbl_error_code::http_status_428_precondition_required;
case MAKE_HTTP_HRESULT(429): return xbl_error_code::http_status_429_too_many_requests;
case MAKE_HTTP_HRESULT(431): return xbl_error_code::http_status_431_request_header_fields_too_large;
case MAKE_HTTP_HRESULT(449): return xbl_error_code::http_status_449_retry_with;
case MAKE_HTTP_HRESULT(451): return xbl_error_code::http_status_451_unavailable_for_legal_reasons;
case HTTP_E_STATUS_SERVER_ERROR: return xbl_error_code::http_status_500_internal_server_error;
case HTTP_E_STATUS_NOT_SUPPORTED: return xbl_error_code::http_status_501_not_implemented;
case HTTP_E_STATUS_BAD_GATEWAY: return xbl_error_code::http_status_502_bad_gateway;
case HTTP_E_STATUS_SERVICE_UNAVAIL: return xbl_error_code::http_status_503_service_unavailable;
case HTTP_E_STATUS_GATEWAY_TIMEOUT: return xbl_error_code::http_status_504_gateway_timeout;
case HTTP_E_STATUS_VERSION_NOT_SUP: return xbl_error_code::http_status_505_http_version_not_supported;
case MAKE_HTTP_HRESULT(506): return xbl_error_code::http_status_506_variant_also_negotiates;
case MAKE_HTTP_HRESULT(507): return xbl_error_code::http_status_507_insufficient_storage;
case MAKE_HTTP_HRESULT(508): return xbl_error_code::http_status_508_loop_detected;
case MAKE_HTTP_HRESULT(510): return xbl_error_code::http_status_510_not_extended;
case MAKE_HTTP_HRESULT(511): return xbl_error_code::http_status_511_network_authentication_required;
default: return xbl_error_code::generic_error;
}
}