Skip to content

Commit ade9c8d

Browse files
6543techknowlogick
andauthored
[API] If User is Admin, show 500 error message on PROD mode too (#13115)
* API: show admin 500 error message on PROD mode too * a nit * dont miss InternalServerError Co-authored-by: techknowlogick <[email protected]>
1 parent f4ffe8e commit ade9c8d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

models/migrations/migrations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,9 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
320320
return nil
321321
}
322322

323-
// Downgraded Gitea not supported
323+
// Downgrading Gitea's database version not supported
324324
if int(v-minDBVersion) > len(migrations) {
325-
msg := fmt.Sprintf("Downgrading Gitea from '%d' to '%d' is not supported and may result in loss of data integrity.\nIf you really know what you're doing, execute `UPDATE version SET version=%d WHERE id=1;`\n",
325+
msg := fmt.Sprintf("Downgrading database version from '%d' to '%d' is not supported and may result in loss of data integrity.\nIf you really know what you're doing, execute `UPDATE version SET version=%d WHERE id=1;`\n",
326326
v, minDBVersion+len(migrations), minDBVersion+len(migrations))
327327
fmt.Fprint(os.Stderr, msg)
328328
log.Fatal(msg)

modules/context/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
8282
if status == http.StatusInternalServerError {
8383
log.ErrorWithSkip(1, "%s: %s", title, message)
8484

85-
if macaron.Env == macaron.PROD {
85+
if macaron.Env == macaron.PROD && !(ctx.User != nil && ctx.User.IsAdmin) {
8686
message = ""
8787
}
8888
}
@@ -99,7 +99,7 @@ func (ctx *APIContext) InternalServerError(err error) {
9999
log.ErrorWithSkip(1, "InternalServerError: %v", err)
100100

101101
var message string
102-
if macaron.Env != macaron.PROD {
102+
if macaron.Env != macaron.PROD || (ctx.User != nil && ctx.User.IsAdmin) {
103103
message = err.Error()
104104
}
105105

0 commit comments

Comments
 (0)