WebErrorStatus Enum

Definition

Defines errors encountered during operations involving web services, such as authentication, proxy configuration, and destination URIs.

public enum class WebErrorStatus
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
enum class WebErrorStatus
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public enum WebErrorStatus
var value = Windows.Web.WebErrorStatus.unknown
Public Enum WebErrorStatus
Inheritance
WebErrorStatus
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Fields

BadGateway 502

The server was acting as a gateway or proxy and received an invalid response from the upstream server.

BadRequest 400

The request cannot be fulfilled due to bad syntax.

CannotConnect 14

Cannot connect to destination.

CertificateCommonNameIsIncorrect 1

The SSL certificate common name does not match the web address.

CertificateContainsErrors 3

The SSL certificate contains errors.

CertificateExpired 2

The SSL certificate has expired.

CertificateIsInvalid 5

The SSL certificate is invalid.

CertificateRevoked 4

The SSL certificate has been revoked.

Conflict 409

Indicates that the request could not be processed because of conflict in the request.

ConnectionAborted 9

The connection was aborted.

ConnectionReset 10

The connection was reset.

Disconnected 11

The connection was ended.

ErrorHttpInvalidServerResponse 8

The server returned an invalid or unrecognized response.

ExpectationFailed 417

The server cannot meet the requirements of the Expect request-header field.

Forbidden 403

The server has refused the request.

Found 302

The resource was found but is available in a location different from the one included in the request.

GatewayTimeout 504

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.

Gone 410

Indicates that the resource requested is no longer available and will not be available again.

HostNameNotResolved 15

Could not resolve provided host name.

HttpsToHttpOnRedirection 13

Redirected from a secure location to an unsecure location.

HttpToHttpsOnRedirection 12

Redirected from a location to a secure location.

HttpVersionNotSupported 505

The server does not support the HTTP protocol version used in the request.

InsufficientRangeSupport 22

The request does not support the range.

InternalServerError 500

A generic error message, given when no more specific message is suitable.

LengthRequired 411

The request did not specify the length of its content, which is required by the requested resource.

MethodNotAllowed 405

A request was made of a resource using a request method not supported by that resource.

MissingContentLengthSupport 23

The request is mising the file size.

MovedPermanently 301

This and all future requests should be directed to the given URI.

MultipleChoices 300

The requested URL represents a high level grouping of which lower level selections need to be made.

NotAcceptable 406

The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.

NotFound 404

The requested resource could not be found but may be available again in the future.

NotImplemented 501

The server either does not recognize the request method, or it lacks the ability to fulfill the request.

NotModified 304

Indicates the resource has not been modified since last requested.

OperationCanceled 16

The operation was canceled.

PaymentRequired 402

Reserved.

PreconditionFailed 412

The server does not meet one of the preconditions that the requester put on the request.

ProxyAuthenticationRequired 407

The client must first authenticate itself with the proxy.

RedirectFailed 17

The request redirect failed.

RequestedRangeNotSatisfiable 416

The client has asked for a portion of the file, but the server cannot supply that portion.

RequestEntityTooLarge 413

The request is larger than the server is willing or able to process.

RequestTimeout 408

The server timed out waiting for the request.

RequestUriTooLong 414

Provided URI length exceeds the maximum length the server can process.

SeeOther 303

The response to the request can be found under another URI using a GET method.

ServerUnreachable 6

The server is not responding.

ServiceUnavailable 503

The server is currently unavailable.

TemporaryRedirect 307

The requested resource resides temporarily under a different URI.

Timeout 7

The connection has timed out.

Unauthorized 401

Authentication has failed or credentials have not yet been provided.

UnexpectedClientError 20

An unexpected client-side error has occurred.

UnexpectedRedirection 19

A request was unexpectedly redirected.

UnexpectedServerError 21

An unexpected server-side error has occurred.

UnexpectedStatusCode 18

An unexpected status code indicating a failure was received.

Unknown 0

An unknown error has occurred.

UnsupportedMediaType 415

The request entity has a media type which the server or resource does not support.

UseProxy 305

The requested resource must be accessed through the proxy given by the Location field.

Remarks

A WebErrorStatus value is returned by Windows.Web.WebError.GetStatus, Windows.Networking.WebSocketError.GetStatus, and Windows.Networking.BackgroundTransfer.GetStatus.

This example demonstrates how to use WebErrorStatus to display a different error message depending on the type of error. In this example, the WebErrorStatus value is returned by Windows.Networking.WebSocketError.GetStatus.

using Windows.Web;
using Windows.Networking.Sockets;

// Pointer back to the main page. Needed to call methods in MainPage such as NotifyUser()
MainPage rootPage = MainPage.Current;

WebErrorStatus status = WebSocketError.GetStatus(ex.GetBaseException().HResult);

if (status == WebErrorStatus.CannotConnect ||
    status == WebErrorStatus.NotFound || 
    status == WebErrorStatus.RequestTimeout)
{
    rootPage.NotifyUser("Cannot connect to the server", NotifyType.ErrorMessage);
}
else
{
    rootPage.NotifyUser("Error: " + status, NotifyType.ErrorMessage);
}
// Pointer back to the main page. Needed to call methods in MainPage such as NotifyUser().
m_rootPage = MainPage::Current();

Windows::Web::WebErrorStatus status{ Windows::Networking::Sockets::WebSocketError::GetStatus(exception.to_abi()) };

if (status == Windows::Web::WebErrorStatus::CannotConnect ||
    status == Windows::Web::WebErrorStatus::NotFound ||
    status == Windows::Web::WebErrorStatus::RequestTimeout)
{
    m_rootPage.NotifyUser(L"Cannot connect to the server", NotifyType::ErrorMessage);
}
else
{
    m_rootPage.NotifyUser(std::wstring(L"Error: ") + exception.message().c_str(), NotifyType::ErrorMessage);
}
using namespace Windows::Web;
using namespace Windows::Networking::Sockets;

// Pointer back to the main page. Needed to call methods in MainPage such as NotifyUser()
rootPage = MainPage::Current;

WebErrorStatus status = WebSocketError::GetStatus(exception->HResult);

if (status == WebErrorStatus::CannotConnect || 
    status == WebErrorStatus::NotFound || 
    status == WebErrorStatus::RequestTimeout)
{
    rootPage->NotifyUser("Cannot connect to the server", NotifyType::ErrorMessage);
}
else
{
    rootPage->NotifyUser("Error: " + status.ToString(), NotifyType::ErrorMessage);
}

Version history

Windows version SDK version Value added
1709 16299 InsufficientRangeSupport
1709 16299 MissingContentLengthSupport

Applies to

See also