1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-05 22:53:41 +02:00

add client closed (#993)

This commit is contained in:
longxboy 2021-06-02 22:58:43 +08:00 committed by GitHub
parent 7bef6cc7d4
commit 5051609aef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -77,7 +77,7 @@ func IsServiceUnavailable(err error) bool {
return Code(err) == 503
}
// GatewayTimeout new ServiceUnavailable error that is mapped to a HTTP 504 response.
// GatewayTimeout new GatewayTimeout error that is mapped to a HTTP 504 response.
func GatewayTimeout(reason, message string) *Error {
return Newf(504, reason, message)
}
@ -87,3 +87,14 @@ func GatewayTimeout(reason, message string) *Error {
func IsGatewayTimeout(err error) bool {
return Code(err) == 504
}
// ClientClosed new ClientClosed error that is mapped to a HTTP 499 response.
func ClientClosed(reason, message string) *Error {
return Newf(499, reason, message)
}
// IsClientClosed determines if err is an error which indicates a IsClientClosed error.
// It supports wrapped errors.
func IsClientClosed(err error) bool {
return Code(err) == 499
}