X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=api%2Fconst.go;h=d3e5f42a485a27ced0feff2a89611686e1a23f59;hb=908ee2dd22c85d5d850f62b1a9d0066b43b80a69;hp=2edd6f4b941f2defe30b4b6a7f87efa1b69aff7f;hpb=7a9e5112eaaea58d55f181d3e5296e4ff839921c;p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FFront.git diff --git a/api/const.go b/api/const.go index 2edd6f4..d3e5f42 100644 --- a/api/const.go +++ b/api/const.go @@ -6,15 +6,20 @@ import "net/http" type Status uint32 type ErrorCode uint32 +const EXTERNAL_SERVICE_TIMEOUT_SECONDS = 10 + const ( OK Status = iota NOK BadRequest ErrorCode = iota + 1 EmailExists + ExternalServiceTimeout InternalError InvalidCredentials InvalidEmail + InvalidMarketCredentials + IPRestrictedApiKey InvalidOtp InvalidPassword NeedOtpValidation @@ -31,7 +36,7 @@ func StatusToHttpCode(status Status, code ErrorCode) int { } switch code { - case BadRequest, InvalidPassword, InvalidEmail: + case BadRequest, InvalidPassword, InvalidEmail, InvalidMarketCredentials, IPRestrictedApiKey: return http.StatusBadRequest case InvalidCredentials, InvalidOtp: @@ -45,6 +50,9 @@ func StatusToHttpCode(status Status, code ErrorCode) int { case NotFound: return http.StatusNotFound + + case ExternalServiceTimeout: + return http.StatusGatewayTimeout } return http.StatusInternalServerError