- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
5. API reference
        Stratis Dermanoutsos edited this page Jul 28, 2025 
        ·
        11 revisions
      
    Used to enforce the implementation of a default message by all different instances of RestException.
public interface IRestException
{
    static abstract string DefaultMessage { get; }
}Members:
- 
DefaultMessage: (static, abstract) Used when the user does not provide a message when throwing an exception. For eachRestExceptioninheritor class, a generic description of the HTTP error's reference has been provided. 
public abstract class RestException(string message, Dictionary<string, object?>? extensions) : Exception(message)
{
    public abstract string Title { get; }
    public abstract HttpStatusCode StatusCode { get; }
    public Dictionary<string, object?> Extensions { get; }
    public string TypeSuffix { get; }
}Members:
- 
Title: (abstract) The title of the HTTP error. This defaults to the error's name. E.g."Not Found"when a 404 is thrown. - 
StatusCode: (abstract) The status of the HTTP error. For more details on this, visit wikipedia. - 
Extensions: A dictionary used to add custom properties to the resultingProblemDetailsresponse. - 
TypeSuffix: Returns the concatenated string that consist ofStatusCodeandTitlejoined by"-"in kebab case. 
References:
Interface used for implementing custom ProblemDetails builders.
public interface IRestExceptionProblemDetailsBuilder
{
    ProblemDetails Build(HttpContext httpContext, RestException restException);
}Members:
- 
Build: It consumes anHttpContextand aRestExceptioninstance to produce the end result. 
References:
public sealed class DefaultRestExceptionProblemDetailsBuilder : IRestExceptionProblemDetailsBuilder
{
    // ...
}The default implementation used by the package itself. Can be used to more easily define a custom builder.
Grouped by their status code's first digit and sorted
- 
4xx(client error)- (400) 
BadRequestRestException - (401) 
UnauthorizedRestException - (402) 
PaymentRequiredRestException - (403) 
ForbiddenRestException - (404) 
NotFoundRestException - (405) 
MethodNotAllowedRestException - (406) 
NotAcceptableRestException - (407) 
ProxyAuthenticationRequiredRestException - (408) 
RequestTimeoutRestException - (409) 
ConflictRestException - (410) 
GoneRestException - (411) 
LengthRequiredRestException - (412) 
PreconditionFailedRestException - (413) 
ContentTooLargeRestException - (414) 
UriTooLongRestException - (415) 
UnsupportedMediaTypeRestException - (416) 
RangeNotSatisfiableRestException - (417) 
ExpectationFailedRestException - (421) 
MisdirectedRequestRestException - (422) 
UnprocessableContentRestException - (423) 
LockedRestException - (424) 
FailedDependencyRestException - (426) 
UpgradeRequiredRestException - (428) 
PreconditionRequiredRestException - (429) 
TooManyRequestsRestException - (431) 
RequestHeaderFieldsTooLargeRestException - (451) 
UnavailableForLegalReasonsRestException 
 - (400) 
 - 
5xx(server error)- (500) 
InternalServerErrorRestException - (501) 
NotImplementedRestException - (502) 
BadGatewayRestException - (503) 
ServiceUnavailableRestException - (504) 
GatewayTimeoutRestException - (505) 
HttpVersionNotSupportedRestException - (506) 
VariantAlsoNegotiatesRestException - (507) 
InsufficientStorageRestException - (508) 
LoopDetectedRestException - (510) 
NotExtendedRestException - (511) 
NetworkAuthenticationRequiredRestException 
 - (500) 
 
Copyright © Stratis Dermanoutsos 2025