ExceptionDescriptorResult Class
Definition
- Namespace
- Cuemon.AspNetCore.Mvc
- Assemblies
- 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
| Name | Description |
|---|---|
| ExceptionDescriptorResult(HttpExceptionDescriptor) | Initializes a new instance of the ExceptionDescriptorResult class. |
| ExceptionDescriptorResult(ProblemDetails) | Initializes a new instance of the ExceptionDescriptorResult class. |