Siemens.AspNet.ErrorHandling.Contracts
3.0.0
Prefix Reserved
dotnet add package Siemens.AspNet.ErrorHandling.Contracts --version 3.0.0
NuGet\Install-Package Siemens.AspNet.ErrorHandling.Contracts -Version 3.0.0
<PackageReference Include="Siemens.AspNet.ErrorHandling.Contracts" Version="3.0.0" />
paket add Siemens.AspNet.ErrorHandling.Contracts --version 3.0.0
#r "nuget: Siemens.AspNet.ErrorHandling.Contracts, 3.0.0"
// Install Siemens.AspNet.ErrorHandling.Contracts as a Cake Addin #addin nuget:?package=Siemens.AspNet.ErrorHandling.Contracts&version=3.0.0 // Install Siemens.AspNet.ErrorHandling.Contracts as a Cake Tool #tool nuget:?package=Siemens.AspNet.ErrorHandling.Contracts&version=3.0.0
Siemens.AspNet.ErrorHandling.Contracts
This package provides the essential data types and base classes used for error handling in ASP.NET Core applications. These classes are designed to standardize error responses and ensure consistency across different layers of your application.
We adhere to the RFC 7807 specification, which defines a standardized format for representing problem details in HTTP APIs. By using RFC 7807 , we ensure that error responses are consistent, easily interpretable by clients, and capable of conveying rich, structured information about errors. This approach enhances interoperability and helps developers diagnose issues more effectively.
Installation
To install the Siemens.AspNet.ErrorHandling.Contracts
package, you can use the NuGet Package Manager Console or the .NET CLI:
NuGet Package Manager Console
Install-Package Siemens.AspNet.ErrorHandling.Contracts
.NET CLI
dotnet add package Siemens.AspNet.ErrorHandling.Contracts
Related Packages
Siemens.AspNet.ErrorHandling
: This package contains the middleware for handling errors in ASP.NET Core applications.
It also contains generic errorhandler to handle errors when no middleware can be used (for example in lambda).
This package has Siemens.AspNet.ErrorHandling.Contracts
included.
ProblemDetails - ProblemDetailsException
This base class is a model for representing problem details in HTTP responses. It is designed to be compatible with RFC 7807 (Problem Details for HTTP APIs). Use this class as a base for your custom error response types.
ValidationProblemDetails - ValidationProblemDetailsException
This class inherits from ProblemDetails and adds additional fields specifically for validation errors. It is used to represent the details of one or more validation failures that occurred during a request.
Why you shouldn’t directly use ProblemDetailsException
or ValidationProblemDetailsException
ProblemDetailsException
and ValidationProblemDetailsException
serve as base classes (or “root classes”) for more specialized exceptions. While they’re provided by the framework to help shape error responses according to the RFC 7807: Problem Details for HTTP APIs specification, they are not intended for direct, everyday use in your application. Instead, you should:
Extend:
If you need custom error-handling logic, create your own exception classes that inherit from these root classes. This approach allows you to add or override properties and methods, ensuring your exceptions contain meaningful context about the errors they represent.Maintain clarity and structure:
Using derived classes helps keep your code organized and intention-revealing. By naming your custom exceptions clearly (e.g.,InvalidOrderException
,UserRegistrationFailedException
), you communicate the specific error context and keep your codebase easier to maintain.Promote flexibility:
As your application grows, you may need additional logic, fields, or response behavior for certain types of errors. Inheriting from these root classes gives you the freedom to evolve your exceptions over time without disrupting the broader error-handling infrastructure.
Classes - ProblemDetails Based
300 Ambiguous - AmbigousDetailsException
Equivalent to HTTP status 300. <see cref="F:System.Net.HttpStatusCode.Ambiguous" /> indicates that the requested information has multiple representations. The default action is to treat this status as a redirect and follow the contents of the Location header associated with this response. Ambiguous is a synonym for MultipleChoices.
300 MultipleChoices - MultipleChoicesDetailsException
Equivalent to HTTP status 300. <see cref="F:System.Net.HttpStatusCode.MultipleChoices" /> indicates that the requested information has multiple representations. The default action is to treat this status as a redirect and follow the contents of the Location header associated with this response. MultipleChoices is a synonym for Ambiguous.
301 Moved - MovedDetailsException
Equivalent to HTTP status 301. <see cref="F:System.Net.HttpStatusCode.Moved" /> indicates that the requested information has been moved to the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will use the GET method. Moved is a synonym for MovedPermanently.
301 MovedPermanently - MovedPermanentlyDetailsException
Equivalent to HTTP status 301. <see cref="F:System.Net.HttpStatusCode.MovedPermanently" /> indicates that the requested information has been moved to the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. MovedPermanently is a synonym for Moved.
302 Found - FoundDetailsException
Equivalent to HTTP status 302. <see cref="F:System.Net.HttpStatusCode.Found" /> indicates that the requested information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will use the GET method. Found is a synonym for Redirect.
302 Redirect - RedirectDetailsException
Equivalent to HTTP status 302. <see cref="F:System.Net.HttpStatusCode.Redirect" /> indicates that the requested information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will use the GET method. Redirect is a synonym for Found.
303 RedirectMethod - RedirectMethodDetailsException
Equivalent to HTTP status 303. <see cref="F:System.Net.HttpStatusCode.RedirectMethod" /> automatically redirects the client to the URI specified in the Location header as the result of a POST. The request to the resource specified by the Location header will be made with a GET. RedirectMethod is a synonym for SeeOther.
303 SeeOther - SeeOtherDetailsException
Equivalent to HTTP status 303. <see cref="F:System.Net.HttpStatusCode.SeeOther" /> automatically redirects the client to the URI specified in the Location header as the result of a POST. The request to the resource specified by the Location header will be made with a GET. SeeOther is a synonym for RedirectMethod.
304 NotModified - NotModifiedDetailsException
Equivalent to HTTP status 304. <see cref="F:System.Net.HttpStatusCode.NotModified" /> indicates that the client's cached copy is up to date. The contents of the resource are not transferred.
305 UseProxy - UseProxyDetailsException
Equivalent to HTTP status 305. <see cref="F:System.Net.HttpStatusCode.UseProxy" /> indicates that the request should use the proxy server at the URI specified in the Location header.
306 Unused - UnusedDetailsException
Equivalent to HTTP status 306. <see cref="F:System.Net.HttpStatusCode.Unused" /> is a proposed extension to the HTTP/1.1 specification that is not fully specified.
307 RedirectKeepVerb - RedirectKeepVerbDetailsException
Equivalent to HTTP status 307. <see cref="F:System.Net.HttpStatusCode.RedirectKeepVerb" /> indicates that the request information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will also use the POST method. RedirectKeepVerb is a synonym for TemporaryRedirect.
307 TemporaryRedirect - TemporaryRedirectDetailsException
Equivalent to HTTP status 307. <see cref="F:System.Net.HttpStatusCode.TemporaryRedirect" /> indicates that the request information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will also use the POST method. TemporaryRedirect is a synonym for RedirectKeepVerb.
308 PermanentRedirect - PermanentRedirectDetailsException
Equivalent to HTTP status 308. <see cref="F:System.Net.HttpStatusCode.PermanentRedirect" /> indicates that the request information is located at the URI specified in the Location header. The default action when this status is received is to follow the Location header associated with the response. When the original request method was POST, the redirected request will also use the POST method.
400 BadRequest - BadRequestDetailsException
HINT: In case you have validation information, use BadRequestValidationDetailsException.
Equivalent to HTTP status 400. <see cref="F:System.Net.HttpStatusCode.BadRequest" /> indicates that the request could not be understood by the server. <see cref="F:System.Net.HttpStatusCode.BadRequest" /> is sent when no other error is applicable, or if the exact error is unknown or does not have its own error code.
401 Unauthorized - UnauthorizedDetailsException
Equivalent to HTTP status 401. <see cref="F:System.Net.HttpStatusCode.Unauthorized" /> indicates that the requested resource requires authentication. The WWW-Authenticate header contains the details of how to perform the authentication.
402 PaymentRequired - PaymentRequiredDetailsException
Equivalent to HTTP status 402. <see cref="F:System.Net.HttpStatusCode.PaymentRequired" /> is reserved for future use.
403 Forbidden - ForbiddenDetailsException
Equivalent to HTTP status 403. <see cref="F:System.Net.HttpStatusCode.Forbidden" /> indicates that the server refuses to fulfill the request.
404 NotFound - NotFoundDetailsException
Equivalent to HTTP status 404. <see cref="F:System.Net.HttpStatusCode.NotFound" /> indicates that the requested resource does not exist on the server.
405 MethodNotAllowed - MethodNotAllowedDetailsException
Equivalent to HTTP status 405. <see cref="F:System.Net.HttpStatusCode.MethodNotAllowed" /> indicates that the request method (POST or GET) is not allowed on the requested resource.
406 NotAcceptable - NotAcceptableDetailsException
Equivalent to HTTP status 406. <see cref="F:System.Net.HttpStatusCode.NotAcceptable" /> indicates that the client has indicated with Accept headers that it will not accept any of the available representations of the resource.
407 ProxyAuthenticationRequired - ProxyAuthenticationRequiredDetailsException
Equivalent to HTTP status 407. <see cref="F:System.Net.HttpStatusCode.ProxyAuthenticationRequired" /> indicates that the requested proxy requires authentication. The Proxy-authenticate header contains the details of how to perform the authentication.
408 RequestTimeout - RequestTimeoutDetailsException
Equivalent to HTTP status 408. <see cref="F:System.Net.HttpStatusCode.RequestTimeout" /> indicates that the client did not send a request within the time the server was expecting the request.
409 Conflict - ConflictDetailsException
Equivalent to HTTP status 409. <see cref="F:System.Net.HttpStatusCode.Conflict" /> indicates that the request could not be carried out because of a conflict on the server.
410 Gone - GoneDetailsException
Equivalent to HTTP status 410. <see cref="F:System.Net.HttpStatusCode.Gone" /> indicates that the requested resource is no longer available.
411 LengthRequired - LengthRequiredDetailsException
Equivalent to HTTP status 411. <see cref="F:System.Net.HttpStatusCode.LengthRequired" /> indicates that the required Content-length header is missing.
412 PreconditionFailed - PreconditionFailedDetailsException
Equivalent to HTTP status 412. <see cref="F:System.Net.HttpStatusCode.PreconditionFailed" /> indicates that a condition set for this request failed, and the request cannot be carried out. Conditions are set with conditional request headers like If-Match, If-None-Match, or If-Unmodified-Since.
413 RequestEntityTooLarge - RequestEntityTooLargeDetailsException
Equivalent to HTTP status 413. <see cref="F:System.Net.HttpStatusCode.RequestEntityTooLarge" /> indicates that the request is too large for the server to process.
414 RequestUriTooLong - RequestUriTooLongDetailsException
Equivalent to HTTP status 414. <see cref="F:System.Net.HttpStatusCode.RequestUriTooLong" /> indicates that the URI is too long.
415 UnsupportedMediaType - UnsupportedMediaTypeDetailsException
Equivalent to HTTP status 415. <see cref="F:System.Net.HttpStatusCode.UnsupportedMediaType" /> indicates that the request is an unsupported type.
416 RequestedRangeNotSatisfiable - RequestedRangeNotSatisfiableDetailsException
Equivalent to HTTP status 416. <see cref="F:System.Net.HttpStatusCode.RequestedRangeNotSatisfiable" /> indicates that the range of data requested from the resource cannot be returned, either because the beginning of the range is before the beginning of the resource, or the end of the range is after the end of the resource.
417 ExpectationFailed - ExpectationFailedDetailsException
Equivalent to HTTP status 417. <see cref="F:System.Net.HttpStatusCode.ExpectationFailed" /> indicates that an expectation given in an Expect header could not be met by the server.
421 MisdirectedRequest - MisdirectedRequestDetailsException
Equivalent to HTTP status 421. <see cref="F:System.Net.HttpStatusCode.MisdirectedRequest" /> indicates that the request was directed at a server that is not able to produce a response.
422 UnprocessableContent - UnprocessableContentDetailsException
HINT: In case you have validation information, use UnprocessableContentDetailsException.
Equivalent to HTTP status 422. <see cref="F:System.Net.HttpStatusCode.UnprocessableContent" /> indicates that the request was well-formed but was unable to be followed due to semantic errors. UnprocessableContent is a synonym for UnprocessableEntity.
422 UnprocessableEntity - UnprocessableEntityDetailsException
HINT: In case you have validation information, use UnprocessableEntityDetailsException.
Equivalent to HTTP status 422. <see cref="F:System.Net.HttpStatusCode.UnprocessableEntity" /> indicates that the request was well-formed but was unable to be followed due to semantic errors. UnprocessableEntity is a synonym for UnprocessableContent.
423 Locked - LockedDetailsException
Equivalent to HTTP status 423. <see cref="F:System.Net.HttpStatusCode.Locked" /> indicates that the source or destination resource is locked.
424 FailedDependency - FailedDependencyDetailsException
Equivalent to HTTP status 424. <see cref="F:System.Net.HttpStatusCode.FailedDependency" /> indicates that the method couldn't be performed on the resource because the requested action depended on another action and that action failed.
426 UpgradeRequired - UpgradeRequiredDetailsException
Equivalent to HTTP status 426. <see cref="F:System.Net.HttpStatusCode.UpgradeRequired" /> indicates that the client should switch to a different protocol such as TLS/1.0.
428 PreconditionRequired - PreconditionRequiredDetailsException
Equivalent to HTTP status 428. <see cref="F:System.Net.HttpStatusCode.PreconditionRequired" /> indicates that the server requires the request to be conditional.
429 TooManyRequests - TooManyRequestsDetailsException
Equivalent to HTTP status 429. <see cref="F:System.Net.HttpStatusCode.TooManyRequests" /> indicates that the user has sent too many requests in a given amount of time.
431 RequestHeaderFieldsTooLarge - RequestHeaderFieldsTooLargeDetailsException
Equivalent to HTTP status 431. <see cref="F:System.Net.HttpStatusCode.RequestHeaderFieldsTooLarge" /> indicates that the server is unwilling to process the request because its header fields (either an individual header field or all the header fields collectively) are too large.
451 UnavailableForLegalReasons - UnavailableForLegalReasonsDetailsException
Equivalent to HTTP status 451. <see cref="F:System.Net.HttpStatusCode.UnavailableForLegalReasons" /> indicates that the server is denying access to the resource as a consequence of a legal demand.
500 InternalServerError - InternalServerErrorDetailsException
Equivalent to HTTP status 500. <see cref="F:System.Net.HttpStatusCode.InternalServerError" /> indicates that a generic error has occurred on the server.
501 NotImplemented - NotImplementedDetailsException
Equivalent to HTTP status 501. <see cref="F:System.Net.HttpStatusCode.NotImplemented" /> indicates that the server does not support the requested function.
502 BadGateway - BadGatewayDetailsException
Equivalent to HTTP status 502. <see cref="F:System.Net.HttpStatusCode.BadGateway" /> indicates that an intermediate proxy server received a bad response from another proxy or the origin server.
503 ServiceUnavailable - ServiceUnavailableDetailsException
Equivalent to HTTP status 503. <see cref="F:System.Net.HttpStatusCode.ServiceUnavailable" /> indicates that the server is temporarily unavailable, usually due to high load or maintenance.
504 GatewayTimeout - GatewayTimeoutDetailsException
Equivalent to HTTP status 504. <see cref="F:System.Net.HttpStatusCode.GatewayTimeout" /> indicates that an intermediate proxy server timed out while waiting for a response from another proxy or the origin server.
505 HttpVersionNotSupported - HttpVersionNotSupportedDetailsException
Equivalent to HTTP status 505. <see cref="F:System.Net.HttpStatusCode.HttpVersionNotSupported" /> indicates that the requested HTTP version is not supported by the server.
506 VariantAlsoNegotiates - VariantAlsoNegotiatesDetailsException
Equivalent to HTTP status 506. <see cref="F:System.Net.HttpStatusCode.VariantAlsoNegotiates" /> indicates that the chosen variant resource is configured to engage in transparent content negotiation itself and, therefore, isn't a proper endpoint in the negotiation process.
507 InsufficientStorage - InsufficientStorageDetailsException
Equivalent to HTTP status 507. <see cref="F:System.Net.HttpStatusCode.InsufficientStorage" /> indicates that the server is unable to store the representation needed to complete the request.
508 LoopDetected - LoopDetectedDetailsException
Equivalent to HTTP status 508. <see cref="F:System.Net.HttpStatusCode.LoopDetected" /> indicates that the server terminated an operation because it encountered an infinite loop while processing a WebDAV request with "Depth: infinity". This status code is meant for backward compatibility with clients not aware of the 208 status code <see cref="F:System.Net.HttpStatusCode.AlreadyReported" /> appearing in multistatus response bodies.
510 NotExtended - NotExtendedDetailsException
Equivalent to HTTP status 510. <see cref="F:System.Net.HttpStatusCode.NotExtended" /> indicates that further extensions to the request are required for the server to fulfill it.
511 NetworkAuthenticationRequired - NetworkAuthenticationRequiredDetailsException
Equivalent to HTTP status 511. <see cref="F:System.Net.HttpStatusCode.NetworkAuthenticationRequired" /> indicates that the client needs to authenticate to gain network access; it's intended for use by intercepting proxies used to control access to the network.
Classes - ValidationProblemDetails Based
400 BadRequest - BadRequestValidationDetailsException
Equivalent to HTTP status 400. <see cref="F:System.Net.HttpStatusCode.BadRequest" /> indicates that the request could not be understood by the server. <see cref="F:System.Net.HttpStatusCode.BadRequest" /> is sent when no other error is applicable, or if the exact error is unknown or does not have its own error code.
422 UnprocessableContent - UnprocessableContentValidationDetailsException
Equivalent to HTTP status 422. <see cref="F:System.Net.HttpStatusCode.UnprocessableContent" /> indicates that the request was well-formed but was unable to be followed due to semantic errors. UnprocessableContent is a synonym for UnprocessableEntity.
422 UnprocessableEntity - UnprocessableEntityValidationDetailsException
Equivalent to HTTP status 422. <see cref="F:System.Net.HttpStatusCode.UnprocessableEntity" /> indicates that the request was well-formed but was unable to be followed due to semantic errors. UnprocessableEntity is a synonym for UnprocessableContent.
License
This project is licensed under the terms specified in the LICENSE file. Please review the license file for details on usage, limitations, and permissions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Siemens.AspNet.ErrorHandling.Contracts:
Package | Downloads |
---|---|
Siemens.AspNet.ErrorHandling
A library which contains following functions: - Siemens.AspNet ErrorHandling Classes - Siemens.AspNet ErrorHandling Middleware - Siemens.AspNet ErrorHandling ExceptionHandlers |
GitHub repositories
This package is not used by any popular GitHub repositories.