mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-26 02:50:54 +00:00
Add nicer error handling on template compile errors (#21350)
There are repeated issues reported whereby users are unable to interpret the template errors. This PR adds some (somewhat complex) error handling to the panic recovery for template renderering but hopefully makes the interpretation of the error easier. Reference #21344 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
56aabf3e8d
commit
7d2545d183
3 changed files with 225 additions and 1 deletions
|
@ -31,6 +31,18 @@ func GlobalModTime(filename string) time.Time {
|
|||
return timeutil.GetExecutableModTime()
|
||||
}
|
||||
|
||||
// GetAssetFilename returns the filename of the provided asset
|
||||
func GetAssetFilename(name string) (string, error) {
|
||||
filename := filepath.Join(setting.CustomPath, name)
|
||||
_, err := os.Stat(filename)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return name, err
|
||||
} else if err == nil {
|
||||
return filename, nil
|
||||
}
|
||||
return "(builtin) " + name, nil
|
||||
}
|
||||
|
||||
// GetAsset get a special asset, only for chi
|
||||
func GetAsset(name string) ([]byte, error) {
|
||||
bs, err := os.ReadFile(filepath.Join(setting.CustomPath, name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue