Jaa


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

Name Value Description
Unknown 0

An unknown error has occurred.

CertificateCommonNameIsIncorrect 1

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

CertificateExpired 2

The SSL certificate has expired.

CertificateContainsErrors 3

The SSL certificate contains errors.

CertificateRevoked 4

The SSL certificate has been revoked.

CertificateIsInvalid 5

The SSL certificate is invalid.

ServerUnreachable 6

The server is not responding.

Timeout 7

The connection has timed out.

ErrorHttpInvalidServerResponse 8

The server returned an invalid or unrecognized response.

ConnectionAborted 9

The connection was aborted.

ConnectionReset 10

The connection was reset.

Disconnected 11

The connection was ended.

HttpToHttpsOnRedirection 12

Redirected from a location to a secure location.

HttpsToHttpOnRedirection 13

Redirected from a secure location to an unsecure location.

CannotConnect 14

Cannot connect to destination.

HostNameNotResolved 15

Could not resolve provided host name.

OperationCanceled 16

The operation was canceled.

RedirectFailed 17

The request redirect failed.

UnexpectedStatusCode 18

An unexpected status code indicating a failure was received.

UnexpectedRedirection 19

A request was unexpectedly redirected.

UnexpectedClientError 20

An unexpected client-side error has occurred.

UnexpectedServerError 21

An unexpected server-side error has occurred.

InsufficientRangeSupport 22

The request does not support the range.

MissingContentLengthSupport 23

The request is mising the file size.

MultipleChoices 300

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

MovedPermanently 301

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

Found 302

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

SeeOther 303

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

NotModified 304

Indicates the resource has not been modified since last requested.

UseProxy 305

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

TemporaryRedirect 307

The requested resource resides temporarily under a different URI.

BadRequest 400

The request cannot be fulfilled due to bad syntax.

Unauthorized 401

Authentication has failed or credentials have not yet been provided.

PaymentRequired 402

Reserved.

Forbidden 403

The server has refused the request.

NotFound 404

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

MethodNotAllowed 405

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

NotAcceptable 406

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

ProxyAuthenticationRequired 407

The client must first authenticate itself with the proxy.

RequestTimeout 408

The server timed out waiting for the request.

Conflict 409

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

Gone 410

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

LengthRequired 411

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

PreconditionFailed 412

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

RequestEntityTooLarge 413

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

RequestUriTooLong 414

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

UnsupportedMediaType 415

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

RequestedRangeNotSatisfiable 416

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

ExpectationFailed 417

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

InternalServerError 500

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

NotImplemented 501

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

BadGateway 502

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

ServiceUnavailable 503

The server is currently unavailable.

GatewayTimeout 504

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

HttpVersionNotSupported 505

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

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