Table of Contents

Class PreconditionFailedException

Namespace
Cuemon.AspNetCore.Http
Assembly
Cuemon.AspNetCore.dll

The exception that is thrown when the client has indicated preconditions in its headers which the server does not meet.

public class PreconditionFailedException : HttpStatusCodeException, ISerializable
Inheritance
PreconditionFailedException
Implements
Inherited Members

Examples

The following example demonstrates how to use PreconditionFailedException when a conditional request header check fails.

using System;

namespace Cuemon.AspNetCore.Http;

public static class PreconditionFailedExceptionExample
{
    public static void Demonstrate()
    {
        var exception = new PreconditionFailedException(
            "The supplied If-Match value does not match the current ETag.",
            new InvalidOperationException("ETag mismatch."));

        Console.WriteLine(exception.StatusCode);
        Console.WriteLine(exception.InnerException?.Message);
    }
}

Constructors

PreconditionFailedException()

Initializes a new instance of the PreconditionFailedException class.

public PreconditionFailedException()

PreconditionFailedException(Exception)

Initializes a new instance of the PreconditionFailedException class.

public PreconditionFailedException(Exception innerException)

Parameters

innerException Exception

The exception that is the cause of the current exception.

PreconditionFailedException(string, Exception)

Initializes a new instance of the PreconditionFailedException class.

public PreconditionFailedException(string message, Exception innerException = null)

Parameters

message string

The message that describes the HTTP status code.

innerException Exception

The exception that is the cause of the current exception.

See Also