mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
return 500 error msg only if not Production mode
This commit is contained in:
parent
cd7b120174
commit
8467b2cee6
@ -69,6 +69,7 @@ type APIRedirect struct{}
|
|||||||
// If status is 500, also it prints error to log.
|
// If status is 500, also it prints error to log.
|
||||||
func (ctx *APIContext) Error(status int, title string, obj interface{}) {
|
func (ctx *APIContext) Error(status int, title string, obj interface{}) {
|
||||||
var message string
|
var message string
|
||||||
|
|
||||||
if err, ok := obj.(error); ok {
|
if err, ok := obj.(error); ok {
|
||||||
message = err.Error()
|
message = err.Error()
|
||||||
} else {
|
} else {
|
||||||
@ -77,6 +78,10 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
|
|||||||
|
|
||||||
if status == http.StatusInternalServerError {
|
if status == http.StatusInternalServerError {
|
||||||
log.ErrorWithSkip(1, "%s: %s", title, message)
|
log.ErrorWithSkip(1, "%s: %s", title, message)
|
||||||
|
|
||||||
|
if macaron.Env == macaron.PROD {
|
||||||
|
message = ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.JSON(status, APIError{
|
ctx.JSON(status, APIError{
|
||||||
@ -90,8 +95,13 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
|
|||||||
func (ctx *APIContext) InternalServerError(err error) {
|
func (ctx *APIContext) InternalServerError(err error) {
|
||||||
log.ErrorWithSkip(1, "InternalServerError: %v", err)
|
log.ErrorWithSkip(1, "InternalServerError: %v", err)
|
||||||
|
|
||||||
|
var message string
|
||||||
|
if macaron.Env != macaron.PROD {
|
||||||
|
message = err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
ctx.JSON(http.StatusInternalServerError, APIError{
|
ctx.JSON(http.StatusInternalServerError, APIError{
|
||||||
Message: err.Error(),
|
Message: message,
|
||||||
URL: setting.API.SwaggerURL,
|
URL: setting.API.SwaggerURL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user