Skip to content

Commit 231390d

Browse files
committed
Fix bugs
1 parent dae9d31 commit 231390d

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

modules/templates/base.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"code.gitea.io/gitea/modules/log"
1313
"code.gitea.io/gitea/modules/setting"
14+
1415
"github.com/unknwon/com"
1516
)
1617

modules/templates/static.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ func (templates templateFileSystem) Get(name string) (io.Reader, error) {
4949
}
5050

5151
func GetAsset(name string) ([]byte, error) {
52-
customDir := filepath.Join(setting.CustomPath, "templates")
53-
bs, err := ioutil.ReadFile(filepath.Join(customDir, name))
52+
bs, err := ioutil.ReadFile(filepath.Join(setting.CustomPath, name))
5453
if err != nil && !os.IsNotExist(err) {
5554
return nil, err
5655
} else if err == nil {

routers/routes/recovery.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ func (d *dataStore) GetData() map[string]interface{} {
3030
// Although similar to macaron.Recovery() the main difference is that this error will be created
3131
// with the gitea 500 page.
3232
func Recovery() func(next http.Handler) http.Handler {
33+
var isDevelopment = setting.RunMode != "prod"
3334
return func(next http.Handler) http.Handler {
3435
rnd := render.New(render.Options{
3536
Extensions: []string{".tmpl"},
3637
Directory: "templates",
3738
Funcs: templates.NewFuncMap(),
3839
Asset: templates.GetAsset,
3940
AssetNames: templates.GetAssetNames,
40-
IsDevelopment: setting.RunMode != "prod",
41+
IsDevelopment: isDevelopment,
4142
})
4243

4344
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@@ -50,7 +51,11 @@ func Recovery() func(next http.Handler) http.Handler {
5051
if err := recover(); err != nil {
5152
combinedErr := fmt.Sprintf("PANIC: %v\n%s", err, string(log.Stack(2)))
5253
log.Error(combinedErr)
53-
http.Error(w, http.StatusText(500), 500)
54+
if isDevelopment {
55+
http.Error(w, combinedErr, 500)
56+
} else {
57+
http.Error(w, http.StatusText(500), 500)
58+
}
5459
}
5560
}()
5661

0 commit comments

Comments
 (0)