aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-13 00:53:33 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-13 00:53:33 -0400
commit79375cc9de2a848b8f594de890f3bef806d154bf (patch)
tree0de4bace7fe8f08c4d18c9243cabdf8b7ce40c0e /pkg
parent7d4c4352c9b8e594efb5cb28a8fac681546cbf0d (diff)
downloadAtlas-79375cc9de2a848b8f594de890f3bef806d154bf.tar.gz
Atlas-79375cc9de2a848b8f594de890f3bef806d154bf.zip
pkg/api/api0: Import errors from R2Northstar/NorthstarMasterServer@b45ff0ef267712e8bff6cd718bb5dc1afcdec420
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/api0/errors.go52
1 files changed, 52 insertions, 0 deletions
diff --git a/pkg/api/api0/errors.go b/pkg/api/api0/errors.go
new file mode 100644
index 0000000..95b5c00
--- /dev/null
+++ b/pkg/api/api0/errors.go
@@ -0,0 +1,52 @@
+package api0
+
+// ErrorCode represents a known Northstar error code.
+type ErrorCode string
+
+// https://github.com/R2Northstar/NorthstarMasterServer/blob/b45ff0ef267712e8bff6cd718bb5dc1afcdec420/shared/errorcodes.js
+const (
+ ErrorCode_NO_GAMESERVER_RESPONSE ErrorCode = "NO_GAMESERVER_RESPONS" // Couldn't reach game server
+ ErrorCode_BAD_GAMESERVER_RESPONSE ErrorCode = "BAD_GAMESERVER_RESPONSE" // Game server gave an invalid response
+ ErrorCode_UNAUTHORIZED_GAMESERVER ErrorCode = "UNAUTHORIZED_GAMESERVER" // Game server is not authorized to make that request
+ ErrorCode_UNAUTHORIZED_GAME ErrorCode = "UNAUTHORIZED_GAME" // Stryder couldn't confirm that this account owns Titanfall 2
+ ErrorCode_UNAUTHORIZED_PWD ErrorCode = "UNAUTHORIZED_PWD" // Wrong password
+ ErrorCode_STRYDER_RESPONSE ErrorCode = "STRYDER_RESPONSE" // Got bad response from stryder
+ ErrorCode_STRYDER_PARSE ErrorCode = "STRYDER_PARSE" // Couldn't parse stryder response
+ ErrorCode_PLAYER_NOT_FOUND ErrorCode = "PLAYER_NOT_FOUND" // Couldn't find player account
+ ErrorCode_INVALID_MASTERSERVER_TOKEN ErrorCode = "INVALID_MASTERSERVER_TOKEN" // Invalid or expired masterserver token
+ ErrorCode_JSON_PARSE_ERROR ErrorCode = "JSON_PARSE_ERROR" // Error parsing json response
+ ErrorCode_UNSUPPORTED_VERSION ErrorCode = "UNSUPPORTED_VERSION" // The version you are using is no longer supported
+ ErrorCode_DUPLICATE_SERVER ErrorCode = "DUPLICATE_SERVER" // A server with this port already exists for your IP address
+)
+
+// Message returns the default message for error code n.
+func (n ErrorCode) Message() string {
+ switch n {
+ case ErrorCode_NO_GAMESERVER_RESPONSE:
+ return "Couldn't reach game server"
+ case ErrorCode_BAD_GAMESERVER_RESPONSE:
+ return "Game server gave an invalid response"
+ case ErrorCode_UNAUTHORIZED_GAMESERVER:
+ return "Game server is not authorized to make that request"
+ case ErrorCode_UNAUTHORIZED_GAME:
+ return "Stryder couldn't confirm that this account owns Titanfall 2"
+ case ErrorCode_UNAUTHORIZED_PWD:
+ return "Wrong password"
+ case ErrorCode_STRYDER_RESPONSE:
+ return "Got bad response from stryder"
+ case ErrorCode_STRYDER_PARSE:
+ return "Couldn't parse stryder response"
+ case ErrorCode_PLAYER_NOT_FOUND:
+ return "Couldn't find player account"
+ case ErrorCode_INVALID_MASTERSERVER_TOKEN:
+ return "Invalid or expired masterserver token"
+ case ErrorCode_JSON_PARSE_ERROR:
+ return "Error parsing json response"
+ case ErrorCode_UNSUPPORTED_VERSION:
+ return "The version you are using is no longer supported"
+ case ErrorCode_DUPLICATE_SERVER:
+ return "A server with this port already exists for your IP address"
+ default:
+ return string(n)
+ }
+}