From cb5ca8ec25574fe6f3de3447b64bf7bf55690b5c Mon Sep 17 00:00:00 2001 From: clD11 <23483715+clD11@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:00:26 +0100 Subject: [PATCH] refactor: add specific error code for solana custodian link mismatch --- services/wallet/controllers_v3.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/wallet/controllers_v3.go b/services/wallet/controllers_v3.go index 4a7122caf..2cc0b75b3 100644 --- a/services/wallet/controllers_v3.go +++ b/services/wallet/controllers_v3.go @@ -499,18 +499,28 @@ func LinkSolanaAddress(s *Service) handlers.AppHandler { switch { case errors.Is(err, model.ErrWalletNotWhitelisted): return handlers.WrapError(model.ErrWalletNotWhitelisted, "rewards wallet not whitelisted", http.StatusForbidden) + case errors.Is(err, model.ErrChallengeNotFound): return handlers.WrapError(model.ErrChallengeNotFound, "linking challenge not found", http.StatusNotFound) + case errors.Is(err, model.ErrChallengeExpired): return handlers.WrapError(model.ErrChallengeExpired, "linking challenge expired", http.StatusUnauthorized) + case errors.Is(err, model.ErrWalletNotFound): return handlers.WrapError(model.ErrWalletNotFound, "rewards wallet not found", http.StatusNotFound) + case errors.Is(err, errDisabledRegion): return handlers.WrapError(errDisabledRegion, "region is currently disabled for linking", http.StatusBadRequest) + case errors.Is(err, ErrTooManyCardsLinked): return handlers.WrapError(ErrTooManyCardsLinked, "too many wallets linked", http.StatusConflict) + + case errors.Is(err, errCustodianLinkMismatch): + return handlers.WrapError(errCustodianLinkMismatch, "wallet is linked to a different custodian", http.StatusBadRequest) + case errors.As(err, &solErr): return handlers.WrapError(solErr, "invalid solana linking message", http.StatusUnauthorized) + default: return handlers.WrapError(model.ErrInternalServer, "internal server error", http.StatusInternalServerError) }