API Reference ResultStatusConstants - ulfbou/Zentient.Results GitHub Wiki
๐ API Reference: static class โ ResultStatusConstants
Namespace:
Zentient.Results.ConstantsAssembly:Zentient.Results.dllAvailable since:v0.1.0
๐ Summary
Defines standardized numeric codes and string descriptions for common result statuses, primarily based on HTTP status codes, facilitating consistent semantic reporting and protocol adaptation across the Zentient framework.
ResultStatusConstantsprovide a unified reference for status codes and their human-readable descriptions, ensuring seamless interoperability between internal result handling and external protocols like HTTP and gRPC.
๐ก Design Philosophy / Rationale
This class centralizes status code definitions to:
- โ๏ธ Provide clear, unambiguous mappings between internal result statuses and standard protocol codes (especially HTTP).
- ๐ Enable uniform interpretation of results across transports, middleware, and telemetry.
- ๐ ๏ธ Support extensibility by including both common and less frequently used HTTP statuses relevant for granular error handling.
- ๐ฏ Facilitate human-readable descriptions alongside numeric codes for diagnostics and logging.
The split into numeric Code and string Description nested classes allows flexible usage for serialization, messaging, and UI display without ambiguity.
๐ Type Signature
internal static class ResultStatusConstants
๐ Members
Code (int)
| Member Name | Value | Description |
|---|---|---|
Ok |
200 | Standard success response. |
Created |
201 | Resource created successfully. |
Accepted |
202 | Request accepted but processing incomplete. |
NoContent |
204 | Success with no body content. |
MultipleChoices |
300 | Multiple possible responses available. |
MovedPermanently |
301 | Resource moved permanently to new URI. |
Found |
302 | Resource temporarily located elsewhere. |
SeeOther |
303 | Response to be retrieved via GET method. |
NotModified |
304 | Resource has not been modified since last request. |
TemporaryRedirect |
307 | Temporary redirect preserving method and body. |
PermanentRedirect |
308 | Permanent redirect preserving method and body. |
BadRequest |
400 | Malformed or invalid client request. |
Unauthorized |
401 | Authentication failure. |
PaymentRequired |
402 | Reserved for future use. |
Forbidden |
403 | Access denied. |
NotFound |
404 | Requested resource does not exist. |
MethodNotAllowed |
405 | HTTP method not supported on resource. |
NotAcceptable |
406 | Resource representation not acceptable. |
RequestTimeout |
408 | Client request timed out. |
Conflict |
409 | Conflict in request state or data. |
Gone |
410 | Resource no longer available. |
LengthRequired |
411 | Content-Length header required. |
PreconditionFailed |
412 | Preconditions in headers not met. |
PayloadTooLarge |
413 | Request entity too large. |
UriTooLong |
414 | URI is too long. |
UnsupportedMediaType |
415 | Media type not supported. |
RangeNotSatisfiable |
416 | Requested range not satisfiable. |
ExpectationFailed |
417 | Expectation given in headers cannot be met. |
ImATeapot |
418 | Easter egg status, "I'm a teapot." |
UnprocessableEntity |
422 | Semantic validation error or business logic violation. |
Locked |
423 | Resource is locked. |
FailedDependency |
424 | Dependency failure. |
TooEarly |
425 | Early request rejected to avoid replay attacks. |
UpgradeRequired |
426 | Client must upgrade to a different protocol. |
PreconditionRequired |
428 | Precondition required for the request. |
TooManyRequests |
429 | Rate limit exceeded. |
RequestHeaderFieldsTooLarge |
431 | Headers too large for the server to process. |
UnavailableForLegalReasons |
451 | Resource unavailable due to legal reasons. |
InternalServerError |
500 | Generic server-side error. |
NotImplemented |
501 | Requested functionality not implemented. |
BadGateway |
502 | Invalid response from upstream server. |
ServiceUnavailable |
503 | Service temporarily unavailable. |
GatewayTimeout |
504 | Upstream server timed out. |
HttpVersionNotSupported |
505 | HTTP version not supported. |
VariantAlsoNegotiates |
506 | Variant also negotiates error. |
InsufficientStorage |
507 | Insufficient storage to complete the operation. |
LoopDetected |
508 | Infinite loop detected. |
NotExtended |
510 | Further extensions required. |
NetworkAuthenticationRequired |
511 | Network authentication required. |
Description (string)
| Member Name | Value | Description |
|---|---|---|
Ok |
"OK" | Standard success message. |
Created |
"Created" | Resource creation confirmation. |
Accepted |
"Accepted" | Request accepted for processing. |
NoContent |
"No Content" | Successful response with no payload. |
MultipleChoices |
"Multiple Choices" | Multiple response options available. |
MovedPermanently |
"Moved Permanently" | Permanent URI redirection. |
Found |
"Found" | Temporary URI redirection. |
SeeOther |
"See Other" | Retrieve response using GET. |
NotModified |
"Not Modified" | Resource unchanged since last request. |
TemporaryRedirect |
"Temporary Redirect" | Temporary redirection preserving method. |
PermanentRedirect |
"Permanent Redirect" | Permanent redirection preserving method. |
BadRequest |
"Bad Request" | Malformed request syntax. |
Unauthorized |
"Unauthorized" | Authentication needed or failed. |
PaymentRequired |
"Payment Required" | Reserved for future use. |
Forbidden |
"Forbidden" | Access denied to resource. |
NotFound |
"Not Found" | Resource not found. |
MethodNotAllowed |
"Method Not Allowed" | HTTP method not supported. |
NotAcceptable |
"Not Acceptable" | Response format unacceptable. |
RequestTimeout |
"Request Timeout" | Client request timeout. |
Conflict |
"Conflict" | Request conflict detected. |
Gone |
"Gone" | Resource permanently removed. |
LengthRequired |
"Length Required" | Content-Length header required. |
PreconditionFailed |
"Precondition Failed" | Preconditions failed. |
PayloadTooLarge |
"Payload Too Large" | Request payload too large. |
UriTooLong |
"URI Too Long" | URI length exceeds limit. |
UnsupportedMediaType |
"Unsupported Media Type" | Unsupported media format. |
RangeNotSatisfiable |
"Range Not Satisfiable" | Requested range invalid. |
ExpectationFailed |
"Expectation Failed" | Expectation header failed. |
ImATeapot |
"I'm a Teapot" | RFC 2324 April Fools' joke. |
UnprocessableEntity |
"Unprocessable Entity" | Semantic validation or business logic failure. |
Locked |
"Locked" | Resource locked. |
FailedDependency |
"Failed Dependency" | Dependency failure encountered. |
TooEarly |
"Too Early" | Premature request rejected. |
UpgradeRequired |
"Upgrade Required" | Protocol upgrade required. |
PreconditionRequired |
"Precondition Required" | Request requires a precondition. |
TooManyRequests |
"Too Many Requests" | Rate limit exceeded. |
RequestHeaderFieldsTooLarge |
"Request Header Fields Too Large" | Headers too large for processing. |
UnavailableForLegalReasons |
"Unavailable For Legal Reasons" | Resource blocked due to legal issues. |
InternalServerError |
"Internal Server Error" | Generic server error. |
NotImplemented |
"Not Implemented" | Feature not implemented. |
BadGateway |
"Bad Gateway" | Invalid response from upstream. |
ServiceUnavailable |
"Service Unavailable" | Service temporarily down. |
GatewayTimeout |
"Gateway Timeout" | Upstream server timeout. |
HttpVersionNotSupported |
"HTTP Version Not Supported" | Unsupported HTTP version. |
VariantAlsoNegotiates |
"Variant Also Negotiates" | Negotiation failure. |
InsufficientStorage |
"Insufficient Storage" | Not enough storage available. |
LoopDetected |
"Loop Detected" | Detected infinite loop. |
NotExtended |
"Not Extended" | Further extensions required. |
NetworkAuthenticationRequired |
"Network Authentication Required" | Network authentication required. |
ProblemDetails |
"Problem Details" | Problem details error type. |
BusinessLogicError |
"Business Logic Error" | Failure due to business rule violation. |
๐งช Usage Examples
// Using status code constant for HTTP response mapping
int statusCode = ResultStatusConstants.Code.BadRequest;
string statusDescription = ResultStatusConstants.Description.BadRequest;
var resultStatus = new ResultStatus(statusCode, statusDescription);
if (result.Status.Code == ResultStatusConstants.Code.UnprocessableEntity)
{
// Handle semantic validation error
}
โ ๏ธ Remarks
- Codes and descriptions are modeled primarily after HTTP/1.1 status codes (RFC 7231) with some additional status for semantic errors.
- Intended for internal use to unify error handling, not as a replacement for detailed
ErrorInfo. - Both numeric and textual constants should be used together for clearer diagnostics.
- Marked as
internalto encourage encapsulation; adaptors expose mapped statuses externally. - Includes some playful or rarely used codes (
ImATeapot) for completeness and testing.
๐งฉ Integration and Interoperability
| Consumer Layer | Role |
|---|---|
| HTTP Endpoint Adapters | Directly map IResult.Status to HTTP response status codes. |
| gRPC Integration | Used to map to gRPC status codes in adapter layers. |
| Telemetry Systems | Status codes emitted as tags for error classification. |
| Client Libraries | Used for mapping response status to user-facing messages. |
๐ See Also
IResultStatusErrorCodesErrorInfo- HTTP Status Code Registry (RFC 7231)
- Zentient Result and Error Patterns
๐ท๏ธ Tags
#API #ResultStatus #HTTP #Constants #ErrorHandling #Interop #ZentientCore
Last Updated: 2025-06-21 Version: 0.4.0