CustomLibrary.ProblemDetails
1.0.24
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CustomLibrary.ProblemDetails --version 1.0.24
NuGet\Install-Package CustomLibrary.ProblemDetails -Version 1.0.24
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.24" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CustomLibrary.ProblemDetails --version 1.0.24
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CustomLibrary.ProblemDetails, 1.0.24"
#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.24 // Install CustomLibrary.ProblemDetails as a Cake Tool #tool nuget:?package=CustomLibrary.ProblemDetails&version=1.0.24
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | available |
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
Product | Versions 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.
-
net6.0
- Hellang.Middleware.ProblemDetails (>= 6.5.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.