diff options
Diffstat (limited to 'internal/context/api.go')
-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. |