summaryrefslogtreecommitdiff
path: root/golang/pkg/api/errors.go
diff options
context:
space:
mode:
authorJulien Dessaux2024-05-06 00:18:22 +0200
committerJulien Dessaux2024-05-06 00:18:22 +0200
commit427cc77fa3633aca7c4c3377fa26b0e70921a7b5 (patch)
treecc8de99037ab539a0786f568cf217b680ac99ec3 /golang/pkg/api/errors.go
parent[node] fix shortest path to only hop through refueling points (diff)
downloadspacetraders-427cc77fa3633aca7c4c3377fa26b0e70921a7b5.tar.gz
spacetraders-427cc77fa3633aca7c4c3377fa26b0e70921a7b5.tar.bz2
spacetraders-427cc77fa3633aca7c4c3377fa26b0e70921a7b5.zip
[golang] bootstrapped a client in yet another language
Diffstat (limited to '')
-rw-r--r--golang/pkg/api/errors.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/golang/pkg/api/errors.go b/golang/pkg/api/errors.go
new file mode 100644
index 0000000..d39a205
--- /dev/null
+++ b/golang/pkg/api/errors.go
@@ -0,0 +1,23 @@
+package api
+
+import (
+ "encoding/json"
+ "fmt"
+ "time"
+)
+
+type RateLimitError struct {
+ LimitType string `json:"type"`
+ RetryAfter float64 `json:"retryAfter"`
+ LimitBurst int `json:"limitBurst"`
+ LimitPerSecond int `json:"limitPerSecond"`
+ Remaining int `json:"remaining"`
+ Reset time.Time `json:"reset"`
+}
+
+func decode429(msg []byte) (e APIMessage[any, RateLimitError]) {
+ if err := json.Unmarshal(msg, &e); err != nil {
+ panic(fmt.Sprintf("Failed to decode419: %+v", err))
+ }
+ return e
+}