feat: status api

This commit is contained in:
Ilia Denisov
2026-01-07 18:38:06 +02:00
parent 1b0ab7a079
commit 204d3df8cf
20 changed files with 188 additions and 40 deletions
+11 -6
View File
@@ -5,10 +5,13 @@ import (
)
const (
ErrDummy int = -1
ErrStorageFailure int = 1000 + iota
ErrGameNotInitialized
ErrGameStateInvalid
)
ErrStorageFailure int = 1000
ErrGameStateInvalid int = 2000
const (
ErrDummy int = -1
ErrDeleteShipTypeExistingGroup = 5000
ErrDeleteShipTypePlanetProduction = 5001
@@ -68,6 +71,8 @@ func GenericErrorText(code int) string {
return "Dummy"
case ErrStorageFailure:
return "Storage failure"
case ErrGameNotInitialized:
return "Game not yet initialized"
case ErrGameStateInvalid:
return "Invalid game state"
case ErrInputUnknownRace:
@@ -170,13 +175,13 @@ func GenericErrorText(code int) string {
}
type GenericError struct {
code int
Code int
subject string
err error
}
func (ge GenericError) Error() string {
msg := GenericErrorText(ge.code)
msg := GenericErrorText(ge.Code)
if ge.subject != "" {
msg += ": " + ge.subject
}
@@ -187,7 +192,7 @@ func (ge GenericError) Error() string {
}
func newGenericError(code int, arg ...any) error {
e := &GenericError{code: code}
e := &GenericError{Code: code}
if len(arg) > 0 {
i := 0
switch arg[i].(type) {