Table of Contents

Class ExceptionDescriptorResult

Namespace
Cuemon.AspNetCore.Mvc
Assembly
Cuemon.AspNetCore.Mvc.dll

An ObjectResult that when executed will produce a response that varies depending on the encapsulated Exception.

public class ExceptionDescriptorResult : ObjectResult, IStatusCodeActionResult, IActionResult
Inheritance
ExceptionDescriptorResult
Implements
Inherited Members

Examples

The following example shows how can return either an or ASP.NET Core .

using System;
using Cuemon;
using Cuemon.AspNetCore.Diagnostics;
using Cuemon.AspNetCore.Http;
using Cuemon.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;

namespace MyApp.Examples;

public static class ExceptionDescriptorResultExample
{
    public static void Demonstrate()
    {
        var descriptorResult = new ExceptionDescriptorResult(
            new HttpExceptionDescriptor(new BadRequestException("City name is required.")));

        var descriptor = (HttpExceptionDescriptor)descriptorResult.Value;
        Console.WriteLine(descriptor.StatusCode);

        var problemResult = new ExceptionDescriptorResult(
            new ProblemDetails { Title = "Validation failed." });

        Console.WriteLine(problemResult.Value is IDecorator<ProblemDetails>);
    }
}

Constructors

ExceptionDescriptorResult(HttpExceptionDescriptor)

Initializes a new instance of the ExceptionDescriptorResult class.

public ExceptionDescriptorResult(HttpExceptionDescriptor value)

Parameters

value HttpExceptionDescriptor

The HttpExceptionDescriptor value to return.

ExceptionDescriptorResult(ProblemDetails)

Initializes a new instance of the ExceptionDescriptorResult class.

public ExceptionDescriptorResult(ProblemDetails value)

Parameters

value ProblemDetails

The ProblemDetails value to return.

See Also