Table of Contents

Class HttpError

Namespace
System.Web.Http
Assembly
System.Web.Http.dll

Defines a serializable container for storing error information. This information is stored as key/value pairs. The dictionary keys to look up standard error information are available on the HttpErrorKeys type.

public sealed class HttpError : Dictionary<string, object>, IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IDictionary, ICollection, IReadOnlyDictionary<string, object>, IReadOnlyCollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, ISerializable, IDeserializationCallback, IXmlSerializable
Inheritance
HttpError
Implements
IXmlSerializable
Inherited Members

Constructors

HttpError()

Initializes a new instance of the HttpError class.

public HttpError()

HttpError(Exception, bool)

Initializes a new instance of the HttpError class for exception.

public HttpError(Exception exception, bool includeErrorDetail)

Parameters

exception Exception

The exception to use for error information.

includeErrorDetail bool

true to include the exception information in the error; false otherwise

HttpError(string)

Initializes a new instance of the HttpError class containing error message message.

public HttpError(string message)

Parameters

message string

The error message to associate with this instance.

HttpError(ModelStateDictionary, bool)

Initializes a new instance of the HttpError class for modelState.

public HttpError(ModelStateDictionary modelState, bool includeErrorDetail)

Parameters

modelState ModelStateDictionary

The invalid model state to use for error information.

includeErrorDetail bool

true to include exception messages in the error; false otherwise

Properties

ExceptionMessage

Gets or sets the message of the Exception if available.

public string ExceptionMessage { get; set; }

Property Value

string

The message of the Exception if available.

ExceptionType

Gets or sets the type of the Exception if available.

public string ExceptionType { get; set; }

Property Value

string

The type of the Exception if available.

InnerException

Gets the inner Exception associated with this instance if available.

public HttpError InnerException { get; }

Property Value

HttpError

The inner Exception associated with this instance if available.

Message

Gets or sets the high-level, user-visible message explaining the cause of the error. Information carried in this field should be considered public in that it will go over the wire regardless of the IncludeErrorDetailPolicy. As a result care should be taken not to disclose sensitive information about the server or the application.

public string Message { get; set; }

Property Value

string

The high-level, user-visible message explaining the cause of the error. Information carried in this field should be considered public in that it will go over the wire regardless of the IncludeErrorDetailPolicy. As a result care should be taken not to disclose sensitive information about the server or the application.

MessageDetail

Gets or sets a detailed description of the error intended for the developer to understand exactly what failed.

public string MessageDetail { get; set; }

Property Value

string

A detailed description of the error intended for the developer to understand exactly what failed.

ModelState

Gets the ModelState containing information about the errors that occurred during model binding.

public HttpError ModelState { get; }

Property Value

HttpError

The ModelState containing information about the errors that occurred during model binding.

StackTrace

Gets or sets the stack trace information associated with this instance if available.

public string StackTrace { get; set; }

Property Value

string

The stack trace information associated with this instance if available.

Methods

GetPropertyValue<TValue>(string)

Gets a particular property value from this error instance.

public TValue GetPropertyValue<TValue>(string key)

Parameters

key string

The name of the error property.

Returns

TValue

A particular property value from this error instance.

Type Parameters

TValue

The type of the property.