woj-server/internal/e/err.go

25 lines
340 B
Go
Raw Normal View History

2022-09-07 23:34:37 +08:00
package e
2024-04-28 22:58:39 +08:00
import (
"errors"
"net/url"
)
2024-01-06 17:32:05 +08:00
2022-09-20 14:15:21 +08:00
type Status int
2022-09-07 23:34:37 +08:00
2022-09-20 14:15:21 +08:00
func (code Status) String() string {
2022-09-07 23:34:37 +08:00
msg, ok := msgText[code]
if ok {
return msg
}
return msgText[InternalError]
}
2024-01-06 17:32:05 +08:00
2024-04-28 22:58:39 +08:00
func (code Status) QueryString() string {
return url.QueryEscape(code.String())
}
2024-01-06 17:32:05 +08:00
func (code Status) AsError() error {
return errors.New(code.String())
}