mirror of https://github.com/gogs/gogs.git
repo/editor: hide internal error detail
Prevent exposure of server pathpull/5309/head^2
parent
ba7b2cc1f6
commit
512a900202
|
@ -520,6 +520,7 @@ editor.file_changed_while_editing = File content has been changed since you star
|
|||
editor.file_already_exists = A file with name '%s' already exists in this repository.
|
||||
editor.no_changes_to_show = There are no changes to show.
|
||||
editor.fail_to_update_file = Failed to update/create file '%s' with error: %v
|
||||
editor.fail_to_delete_file = Failed to delete file '%s' with error: %v
|
||||
editor.add_subdir = Add subdirectory...
|
||||
editor.unable_to_upload_files = Failed to upload files to '%s' with error: %v
|
||||
editor.upload_files_to_dir = Upload files to '%s'
|
||||
|
|
|
@ -6,6 +6,8 @@ package errors
|
|||
|
||||
import "errors"
|
||||
|
||||
var InternalServerError = errors.New("internal server error")
|
||||
|
||||
// New is a wrapper of real errors.New function.
|
||||
func New(text string) error {
|
||||
return errors.New(text)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"github.com/gogs/git-module"
|
||||
"github.com/gogs/gogs/models"
|
||||
"github.com/gogs/gogs/models/errors"
|
||||
"github.com/gogs/gogs/pkg/context"
|
||||
"github.com/gogs/gogs/pkg/form"
|
||||
"github.com/gogs/gogs/pkg/setting"
|
||||
|
@ -276,8 +277,9 @@ func editFilePost(c *context.Context, f form.EditRepoFile, isNewFile bool) {
|
|||
Content: strings.Replace(f.Content, "\r", "", -1),
|
||||
IsNewFile: isNewFile,
|
||||
}); err != nil {
|
||||
log.Error(2, "Failed to update repo file: %v", err)
|
||||
c.FormErr("TreePath")
|
||||
c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, err), EDIT_FILE, &f)
|
||||
c.RenderWithErr(c.Tr("repo.editor.fail_to_update_file", f.TreePath, errors.InternalServerError), EDIT_FILE, &f)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -380,7 +382,8 @@ func DeleteFilePost(c *context.Context, f form.DeleteRepoFile) {
|
|||
TreePath: c.Repo.TreePath,
|
||||
Message: message,
|
||||
}); err != nil {
|
||||
c.ServerError("DeleteRepoFile", err)
|
||||
log.Error(2, "Failed to delete repo file: %v", err)
|
||||
c.RenderWithErr(c.Tr("repo.editor.fail_to_delete_file", c.Repo.TreePath, errors.InternalServerError), DELETE_FILE, &f)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -499,8 +502,9 @@ func UploadFilePost(c *context.Context, f form.UploadRepoFile) {
|
|||
Message: message,
|
||||
Files: f.Files,
|
||||
}); err != nil {
|
||||
log.Error(2, "Failed to upload files: %v", err)
|
||||
c.FormErr("TreePath")
|
||||
c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, err), UPLOAD_FILE, &f)
|
||||
c.RenderWithErr(c.Tr("repo.editor.unable_to_upload_files", f.TreePath, errors.InternalServerError), UPLOAD_FILE, &f)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue