Class ServiceUnavailableError
- Namespace
- Trellis
- Assembly
- Trellis.Results.dll
Represents a temporary service unavailability error. Use this when the service is temporarily unable to handle the request due to maintenance or overload. Maps to HTTP 503 Service Unavailable.
public sealed class ServiceUnavailableError : Error, IEquatable<Error>
- Inheritance
-
ServiceUnavailableError
- Implements
- Inherited Members
- Extension Methods
Examples
Error.ServiceUnavailable("Service is under maintenance. Please try again later")
Error.ServiceUnavailable("Database connection pool exhausted. Retry in 30 seconds")
Error.ServiceUnavailable("External payment gateway is temporarily unavailable")
Remarks
This indicates a temporary condition - the service is expected to be available again. Include retry-after information in the detail message when appropriate. For permanent unavailability or deprecated endpoints, consider using other error types.
Constructors
ServiceUnavailableError(string, string, string?)
Initializes a new instance of the ServiceUnavailableError class.
public ServiceUnavailableError(string detail, string code, string? instance = null)
Parameters
detailstringDescription of why the service is unavailable.
codestringThe error code identifying this type of service unavailable error.
instancestringOptional identifier for the unavailable service or resource.
ServiceUnavailableError(string, string, RetryAfterValue, string?)
Initializes a new instance of the ServiceUnavailableError class with retry-after metadata.
public ServiceUnavailableError(string detail, string code, RetryAfterValue retryAfter, string? instance = null)
Parameters
detailstringDescription of why the service is unavailable.
codestringThe error code identifying this type of service unavailable error.
retryAfterRetryAfterValueThe retry-after value indicating when the service may resume.
instancestringOptional identifier for the unavailable service or resource.
Properties
RetryAfter
Gets the optional retry-after value indicating when the service may resume.
When present, Trellis response mappers emit the Retry-After header.
public RetryAfterValue? RetryAfter { get; }