static xbox_live_error_code ConvertHrToXblErrorCode()

in Include/xsapi-cpp/impl/public_utils.h [22:103]


    static xbox_live_error_code ConvertHrToXblErrorCode(HRESULT hr)
    {
        switch (hr)
        {
        case S_OK: return xbox_live_error_code::no_error;
        case E_OUTOFMEMORY: return xbox_live_error_code::bad_alloc;
        case E_INVALIDARG: return xbox_live_error_code::invalid_argument;
        case E_XBL_RUNTIME_ERROR: return xbox_live_error_code::runtime_error;
        case __HRESULT_FROM_WIN32(ERROR_BAD_LENGTH): return xbox_live_error_code::length_error;
        case E_BOUNDS: return xbox_live_error_code::out_of_range;

        case E_NOINTERFACE: return xbox_live_error_code::bad_cast;
        case E_UNEXPECTED: return xbox_live_error_code::logic_error;
        case WEB_E_INVALID_JSON_STRING: return xbox_live_error_code::json_error;
        case WEB_E_UNEXPECTED_CONTENT: return xbox_live_error_code::uri_error;
        case ONL_E_ACTION_REQUIRED: return xbox_live_error_code::auth_user_interaction_required;
        case E_XBL_RTA_GENERIC_ERROR: return xbox_live_error_code::rta_generic_error;
        case E_XBL_RTA_SUBSCRIPTION_LIMIT_REACHED: return xbox_live_error_code::rta_subscription_limit_reached;
        case E_XBL_RTA_ACCESS_DENIED: return xbox_live_error_code::rta_access_denied;
        case E_XBL_RTA_NOT_ACTIVATED: return xbox_live_error_code::rta_not_activated;
        case E_XBL_AUTH_UNKNOWN_ERROR: return xbox_live_error_code::auth_unknown_error;
        case E_XBL_AUTH_RUNTIME_ERROR: return xbox_live_error_code::auth_runtime_error;
        case E_XBL_AUTH_NO_TOKEN: return xbox_live_error_code::auth_no_token_error;
        case __HRESULT_FROM_WIN32(ERROR_NO_SUCH_USER): return xbox_live_error_code::auth_user_not_signed_in;
        case __HRESULT_FROM_WIN32(ERROR_CANCELLED): return xbox_live_error_code::auth_user_cancel;
        case __HRESULT_FROM_WIN32(ERROR_BAD_CONFIGURATION): return xbox_live_error_code::invalid_config;
        case E_NOTIMPL: return xbox_live_error_code::unsupported;

            // HTTP errors
        case __HRESULT_FROM_WIN32(ERROR_RESOURCE_DATA_NOT_FOUND): return xbox_live_error_code::http_status_204_resource_data_not_found;
        case HTTP_E_STATUS_AMBIGUOUS: return xbox_live_error_code::http_status_300_multiple_choices;
        case HTTP_E_STATUS_MOVED: return xbox_live_error_code::http_status_301_moved_permanently;
        case HTTP_E_STATUS_REDIRECT: return xbox_live_error_code::http_status_302_found;
        case HTTP_E_STATUS_REDIRECT_METHOD: return xbox_live_error_code::http_status_303_see_other;
        case HTTP_E_STATUS_NOT_MODIFIED: return xbox_live_error_code::http_status_304_not_modified;
        case HTTP_E_STATUS_USE_PROXY: return xbox_live_error_code::http_status_305_use_proxy;
        case HTTP_E_STATUS_REDIRECT_KEEP_VERB: return xbox_live_error_code::http_status_307_temporary_redirect;

        case HTTP_E_STATUS_BAD_REQUEST: return xbox_live_error_code::http_status_400_bad_request;
        case HTTP_E_STATUS_DENIED: return xbox_live_error_code::http_status_401_unauthorized;
        case HTTP_E_STATUS_PAYMENT_REQ: return xbox_live_error_code::http_status_402_payment_required;
        case HTTP_E_STATUS_FORBIDDEN: return xbox_live_error_code::http_status_403_forbidden;
        case HTTP_E_STATUS_NOT_FOUND: return xbox_live_error_code::http_status_404_not_found;
        case HTTP_E_STATUS_BAD_METHOD: return xbox_live_error_code::http_status_405_method_not_allowed;
        case HTTP_E_STATUS_NONE_ACCEPTABLE: return xbox_live_error_code::http_status_406_not_acceptable;
        case HTTP_E_STATUS_PROXY_AUTH_REQ: return xbox_live_error_code::http_status_407_proxy_authentication_required;
        case HTTP_E_STATUS_REQUEST_TIMEOUT: return xbox_live_error_code::http_status_408_request_timeout;
        case HTTP_E_STATUS_CONFLICT: return xbox_live_error_code::http_status_409_conflict;
        case HTTP_E_STATUS_GONE: return xbox_live_error_code::http_status_410_gone;
        case HTTP_E_STATUS_LENGTH_REQUIRED: return xbox_live_error_code::http_status_411_length_required;
        case HTTP_E_STATUS_PRECOND_FAILED: return xbox_live_error_code::http_status_412_precondition_failed;
        case HTTP_E_STATUS_REQUEST_TOO_LARGE: return xbox_live_error_code::http_status_413_request_entity_too_large;
        case HTTP_E_STATUS_URI_TOO_LONG: return xbox_live_error_code::http_status_414_request_uri_too_long;
        case HTTP_E_STATUS_UNSUPPORTED_MEDIA: return xbox_live_error_code::http_status_415_unsupported_media_type;
        case HTTP_E_STATUS_RANGE_NOT_SATISFIABLE: return xbox_live_error_code::http_status_416_requested_range_not_satisfiable;
        case HTTP_E_STATUS_EXPECTATION_FAILED: return xbox_live_error_code::http_status_417_expectation_failed;
        case MAKE_HTTP_HRESULT(421): return xbox_live_error_code::http_status_421_misdirected_request;
        case MAKE_HTTP_HRESULT(422): return xbox_live_error_code::http_status_422_unprocessable_entity;
        case MAKE_HTTP_HRESULT(423): return xbox_live_error_code::http_status_423_locked;
        case MAKE_HTTP_HRESULT(424): return xbox_live_error_code::http_status_424_failed_dependency;
        case MAKE_HTTP_HRESULT(426): return xbox_live_error_code::http_status_426_upgrade_required;
        case MAKE_HTTP_HRESULT(428): return xbox_live_error_code::http_status_428_precondition_required;
        case MAKE_HTTP_HRESULT(429): return xbox_live_error_code::http_status_429_too_many_requests;
        case MAKE_HTTP_HRESULT(431): return xbox_live_error_code::http_status_431_request_header_fields_too_large;
        case MAKE_HTTP_HRESULT(449): return xbox_live_error_code::http_status_449_retry_with;
        case MAKE_HTTP_HRESULT(451): return xbox_live_error_code::http_status_451_unavailable_for_legal_reasons;

        case HTTP_E_STATUS_SERVER_ERROR: return xbox_live_error_code::http_status_500_internal_server_error;
        case HTTP_E_STATUS_NOT_SUPPORTED: return xbox_live_error_code::http_status_501_not_implemented;
        case HTTP_E_STATUS_BAD_GATEWAY: return xbox_live_error_code::http_status_502_bad_gateway;
        case HTTP_E_STATUS_SERVICE_UNAVAIL: return xbox_live_error_code::http_status_503_service_unavailable;
        case HTTP_E_STATUS_GATEWAY_TIMEOUT: return xbox_live_error_code::http_status_504_gateway_timeout;
        case HTTP_E_STATUS_VERSION_NOT_SUP: return xbox_live_error_code::http_status_505_http_version_not_supported;
        case MAKE_HTTP_HRESULT(506): return xbox_live_error_code::http_status_506_variant_also_negotiates;
        case MAKE_HTTP_HRESULT(507): return xbox_live_error_code::http_status_507_insufficient_storage;
        case MAKE_HTTP_HRESULT(508): return xbox_live_error_code::http_status_508_loop_detected;
        case MAKE_HTTP_HRESULT(510): return xbox_live_error_code::http_status_510_not_extended;
        case MAKE_HTTP_HRESULT(511): return xbox_live_error_code::http_status_511_network_authentication_required;

        default: return xbox_live_error_code::generic_error;
        }
    }