Created
July 30, 2025 13:46
-
-
Save cybergitt/a6905ade65f05fe16580d53965c258b2 to your computer and use it in GitHub Desktop.
Api Error from Error Model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using BAS.Application.Common.Constants; | |
| using Microsoft.AspNetCore.Http; | |
| namespace BAS.Application.Common.Errors | |
| { | |
| public static class ApiErrors | |
| { | |
| public static readonly Error Unavailable = new( | |
| code: "unavailable", | |
| message: ApiMessages.Unavailable, | |
| status: StatusCodes.Status503ServiceUnavailable | |
| ); | |
| public static readonly Error GatewayTimeout = new( | |
| code: "gateway_timeout", | |
| message: ApiMessages.GatewayTimeout, | |
| status: StatusCodes.Status503ServiceUnavailable | |
| ); | |
| public static readonly Error BadGateway = new( | |
| code: "bad_gateway", | |
| message: ApiMessages.BadGateway, | |
| status: StatusCodes.Status502BadGateway | |
| ); | |
| public static readonly Error Unexpected = new( | |
| code: "internal_server_error", | |
| message: ApiMessages.Unexpected, | |
| status: StatusCodes.Status500InternalServerError | |
| ); | |
| public static readonly Error TooManyRequest = new( | |
| code: "rate_limit_exceeded", | |
| message: ApiMessages.TooManyRequest, | |
| status: StatusCodes.Status429TooManyRequests | |
| ); | |
| public static readonly Error UnprocessableEntity = new( | |
| code: "unprocessable_entity", | |
| message: ApiMessages.UnprocessableEntity, | |
| status: StatusCodes.Status422UnprocessableEntity | |
| ); | |
| public static readonly Error UnsupportedMediaType = new( | |
| code: "unsupported_media_type", | |
| message: ApiMessages.UnsupportedMediaType, | |
| status: StatusCodes.Status415UnsupportedMediaType | |
| ); | |
| public static readonly Error RequestEntityTooLarge = new( | |
| code: "request_entity_too_large", | |
| message: ApiMessages.RequestEntityTooLarge, | |
| status: StatusCodes.Status413RequestEntityTooLarge | |
| ); | |
| public static readonly Error PreconditionFailed = new( | |
| code: "precondition_failed", | |
| message: ApiMessages.PreconditionFailed, | |
| status: StatusCodes.Status412PreconditionFailed | |
| ); | |
| public static readonly Error LengthRequired = new( | |
| code: "length_required", | |
| message: ApiMessages.LengthRequired, | |
| status: StatusCodes.Status411LengthRequired | |
| ); | |
| public static readonly Error Gone = new( | |
| code: "session_expired", | |
| message: ApiMessages.Gone, | |
| status: StatusCodes.Status410Gone | |
| ); | |
| public static readonly Error Conflict = new( | |
| code: "conflict", | |
| message: ApiMessages.Conflict, | |
| status: StatusCodes.Status409Conflict | |
| ); | |
| public static readonly Error MethodNotAllowed = new( | |
| code: "method_not_allowed", | |
| message: ApiMessages.MethodNotAllowed, | |
| status: StatusCodes.Status405MethodNotAllowed | |
| ); | |
| public static readonly Error NotFound = new( | |
| code: "not_found", | |
| message: ApiMessages.NotFound, | |
| status: StatusCodes.Status404NotFound | |
| ); | |
| public static readonly Error Forbidden = new( | |
| code: "forbidden", | |
| message: ApiMessages.Forbidden, | |
| status: StatusCodes.Status403Forbidden | |
| ); | |
| public static readonly Error Unauthorized = new( | |
| code: "unauthorized", | |
| message: ApiMessages.Unauthorized, | |
| status: StatusCodes.Status401Unauthorized | |
| ); | |
| public static readonly Error BadRequest = new( | |
| code: "bad_request", | |
| message: ApiMessages.BadRequest, | |
| status: StatusCodes.Status400BadRequest | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment