diff options
author | ᴜɴᴋɴᴡᴏɴ <u@gogs.io> | 2020-03-10 22:15:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 22:15:55 +0800 |
commit | 880d0ec19f488001a90b3e370a992eaabac89e70 (patch) | |
tree | 97bcb926b3c94f56cc0367a7a405df1a2d6ad06a /internal/context | |
parent | 2430612ad4190fe81bfb8b64c92fe1883188f856 (diff) |
api: overhaul `/repos/owner/repos/contents` (#5980)
* Fix import path renaming
* api: overhaul /repos/owner/repos/contents
Diffstat (limited to 'internal/context')
-rw-r--r-- | internal/context/api.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/context/api.go b/internal/context/api.go index 881e9aa8..dfea976c 100644 --- a/internal/context/api.go +++ b/internal/context/api.go @@ -39,7 +39,7 @@ func (c *APIContext) Error(status int, title string, obj interface{}) { } if status == http.StatusInternalServerError { - log.Error("%s: %s", title, message) + log.ErrorDepth(5, "%s: %s", title, message) } c.JSON(status, map[string]string{ @@ -63,6 +63,11 @@ func (c *APIContext) ServerError(title string, err error) { c.Error(http.StatusInternalServerError, title, err) } +// Errorf renders the 500 response with formatted message. +func (c *APIContext) Errorf(err error, format string, args ...interface{}) { + c.Error(http.StatusInternalServerError, fmt.Sprintf(format, args...), err) +} + // NotFoundOrServerError use error check function to determine if the error // is about not found. It responses with 404 status code for not found error, // or error context description for logging purpose of 500 server error. |