Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
28 lines
607 B
Go
28 lines
607 B
Go
package platformsettings
|
|
|
|
import "errors"
|
|
|
|
// clientError is a validation message safe to return to API clients.
|
|
type clientError struct {
|
|
msg string
|
|
}
|
|
|
|
func (e *clientError) Error() string { return e.msg }
|
|
|
|
// ClientMsg marks a message as safe to expose in HTTP 4xx responses.
|
|
func ClientMsg(msg string) error {
|
|
return &clientError{msg: msg}
|
|
}
|
|
|
|
// ClientError reports whether err is a known client-facing settings error.
|
|
func ClientError(err error) (msg string, ok bool) {
|
|
if err == nil {
|
|
return "", false
|
|
}
|
|
var ce *clientError
|
|
if errors.As(err, &ce) {
|
|
return ce.msg, true
|
|
}
|
|
return "", false
|
|
}
|