LastMUD/internal/game/command/error.go

34 lines
618 B
Go
Raw Normal View History

2025-06-19 16:22:55 +03:00
package command
2025-06-16 14:59:51 +03:00
import "fmt"
2025-06-18 17:04:06 +03:00
type commandError struct {
2025-06-16 14:59:51 +03:00
cmdName string
message string
}
2025-06-18 17:04:06 +03:00
func createCommandError(cmdName string, msg string, msgArgs ...any) *commandError {
return &commandError{
2025-06-16 14:59:51 +03:00
cmdName: cmdName,
message: fmt.Sprintf(msg, msgArgs...),
}
}
2025-06-18 17:04:06 +03:00
func (cmdErr *commandError) Error() string {
2025-06-16 14:59:51 +03:00
return "Error with command '" + cmdErr.cmdName + "': " + cmdErr.message
}
2025-06-22 22:27:56 +03:00
type commandContextError struct {
err string
}
func createCommandContextError(err string) *commandContextError {
return &commandContextError{
err: err,
}
}
func (cce *commandContextError) Error() string {
return cce.err
}