CustomLibrary.ProblemDetails 1.0.22

There is a newer version of this package available.
See the version list below for details.
dotnet add package CustomLibrary.ProblemDetails --version 1.0.22
NuGet\Install-Package CustomLibrary.ProblemDetails -Version 1.0.22
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CustomLibrary.ProblemDetails" Version="1.0.22" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CustomLibrary.ProblemDetails --version 1.0.22
#r "nuget: CustomLibrary.ProblemDetails, 1.0.22"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CustomLibrary.ProblemDetails as a Cake Addin
#addin nuget:?package=CustomLibrary.ProblemDetails&version=1.0.22

// Install CustomLibrary.ProblemDetails as a Cake Tool
#tool nuget:?package=CustomLibrary.ProblemDetails&version=1.0.22

CustomLibrary.ProblemDetails

Collection of tools related to problem management (exceptions) that can be generated by applications.

This library is an ad hoc code customization used in my private/work projects thus avoiding the duplication of repetitive code.

Configuration in ConfigureServices in Startup.cs

  services.AddProblemDetails();

Configuration in Configure in Startup.cs

  app.UseProblemDetails();

Example of use

  [HttpGet("{id}")]
  public async Task<IActionResult> GetPerson(Guid id)
  {
    try
    {
      var person = await myService.GetItemAsync(id);

      if (person == null)
      {
        throw new CustomLibrary.ProblemDetails.Exception.NotFoundException($"Person with id {id} not found");
      }

      return Ok(new CustomLibrary.ProblemDetails.Response.Confirm(person));
    }
    catch (NotFoundException exc)
    {
      return CustomLibrary.ProblemDetails.Response.NotFound(HttpContext, exc);
    }
  }

List of Exception Responses

Status Codes Exception Exception Response
304 Exception.NotModifiedException Response.NotModified available
400 Exception.BadRequestException Response.BadRequest available
401 Exception.UnauthorizedException Response.Unauthorized available
403 Exception.ForbiddenException Response.Forbidden available
404 Exception.NotFoundException Response.NotFound available
405 Exception.NotAllowedException Response.MethodNotAllowed available
406 Exception.NotAcceptableException Response.NotAcceptable available
408 Exception.RequestTimeoutException Response.RequestTimeout available
409 Exception.ConflictException Response.Conflict available
422 Exception.UnprocessableEntityException Response.UnprocessableEntity coming soon
500 Exception.InternalServerErrorException Response.InternalServerError coming soon
501 Exception.NotImplementedException Response.NotImplemented coming soon
502 Exception.BadGatewayException Response.BadGateway coming soon
503 Exception.ServiceUnavailableException Response.ServiceUnavailable coming soon
504 Exception.GatewayTimeoutException Response.GatewayTimeout coming soon

Contributing

Contributions and/or suggestions are always welcome.

License

GitHub License

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 159 12/21/2023
1.0.35 149 10/31/2023
1.0.33 94 10/30/2023
1.0.31 111 10/28/2023
1.0.29 96 10/24/2023
1.0.26 116 9/25/2023
1.0.24 108 9/12/2023
1.0.22 146 8/29/2023