refactor APIError to accept string message

This commit is contained in:
copilot-swe-agent[bot]
2026-06-06 11:53:36 +00:00
committed by GitHub
parent 72d4a2a314
commit 1279c0a320
66 changed files with 512 additions and 504 deletions

View File

@@ -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{}