From 880d0ec19f488001a90b3e370a992eaabac89e70 Mon Sep 17 00:00:00 2001 From: ᴜɴᴋɴᴡᴏɴ Date: Tue, 10 Mar 2020 22:15:55 +0800 Subject: api: overhaul `/repos/owner/repos/contents` (#5980) * Fix import path renaming * api: overhaul /repos/owner/repos/contents --- internal/context/api.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'internal/context') 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. -- cgit v1.2.3