aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/api0
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-19 03:04:43 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-19 03:04:43 -0400
commit1df6f9a765a9f4371757545be963c1fcb2bafa95 (patch)
treedb4b62f25b1277fa04a5881902fe250d3a856328 /pkg/api/api0
parent36bc4748543380a55b3d1c9de08cfd867f5707df (diff)
downloadAtlas-1df6f9a765a9f4371757545be963c1fcb2bafa95.tar.gz
Atlas-1df6f9a765a9f4371757545be963c1fcb2bafa95.zip
pkg/api/api0: Use different error code for a2s timeout when verifying server
Diffstat (limited to 'pkg/api/api0')
-rw-r--r--pkg/api/api0/server.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/pkg/api/api0/server.go b/pkg/api/api0/server.go
index 68c94c9..9834c1b 100644
--- a/pkg/api/api0/server.go
+++ b/pkg/api/api0/server.go
@@ -316,7 +316,14 @@ func (h *Handler) handleServerUpsert(w http.ResponseWriter, r *http.Request) {
}
if err := a2s.Probe(s.Addr, time.Until(nsrv.VerificationDeadline)); err != nil {
- respFail(w, r, http.StatusBadGateway, ErrorCode_BAD_GAMESERVER_RESPONSE.MessageObjf("failed to connect to game port: %v", err))
+ var code ErrorCode
+ switch {
+ case errors.Is(err, a2s.ErrTimeout):
+ code = ErrorCode_NO_GAMESERVER_RESPONSE
+ default:
+ code = ErrorCode_BAD_GAMESERVER_RESPONSE
+ }
+ respFail(w, r, http.StatusBadGateway, code.MessageObjf("failed to connect to game port: %v", err))
return
}