mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-29 10:31:38 +00:00
refactor APIError to accept string message
This commit is contained in:
committed by
GitHub
parent
72d4a2a314
commit
1279c0a320
@@ -155,6 +155,14 @@ func (ctx *APIContext) APIError(status int, msg string) {
|
||||
})
|
||||
}
|
||||
|
||||
// APIErrorMessage converts any object to an API error message.
|
||||
func (ctx *APIContext) APIErrorMessage(obj any) string {
|
||||
if err, ok := obj.(error); ok {
|
||||
return err.Error()
|
||||
}
|
||||
return fmt.Sprintf("%s", obj)
|
||||
}
|
||||
|
||||
type apiContextKeyType struct{}
|
||||
|
||||
var apiContextKey = apiContextKeyType{}
|
||||
|
||||
Reference in New Issue
Block a user