api: overhaul /repos/owner/repos/contents (#5980)

* Fix import path renaming

* api: overhaul /repos/owner/repos/contents
This commit is contained in:
ᴜɴᴋɴᴡᴏɴ
2020-03-10 22:15:55 +08:00
committed by GitHub
parent 2430612ad4
commit 880d0ec19f
4 changed files with 232 additions and 243 deletions

View File

@@ -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.