5 //go:generate stringer -type=Status,ErrorCode -output const_string.go
9 const EXTERNAL_SERVICE_TIMEOUT_SECONDS = 20
15 BadRequest ErrorCode = iota + 1
17 ExternalServiceTimeout
21 InvalidMarketCredentials
33 func StatusToHttpCode(status Status, code ErrorCode) int {
39 case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey:
40 return http.StatusBadRequest
42 case InvalidCredentials, InvalidOtp:
43 return http.StatusUnauthorized
45 case UserNotConfirmed, NotAuthorized, OtpAlreadySetup, OtpNotSetup, NeedOtpValidation:
46 return http.StatusForbidden
49 return http.StatusConflict
52 return http.StatusNotFound
54 case ExternalServiceTimeout:
55 return http.StatusGatewayTimeout
58 return http.StatusInternalServerError