statusCode property
int
get
statusCode
Returns the HTTP status code associated with this error.
Maps ServiceErrorCode values to their corresponding HTTP status codes for easier integration with HTTP-based error handling.
Returns the appropriate HTTP status code (400-500 range).
Implementation
int get statusCode {
switch (code) {
case ServiceErrorCode.notFound:
return 404;
case ServiceErrorCode.unauthorized:
return 401;
case ServiceErrorCode.badRequest:
return 400;
case ServiceErrorCode.forbidden:
return 403;
case ServiceErrorCode.tooManyRequests:
return 429;
case ServiceErrorCode.internal:
default:
return 500;
}
}