Improve error handling in request value execution
- Modify request value execution to log errors when method calls fail - Prevent propagation of errors during value resolution - Update error message in data merging to be more descriptive
This commit is contained in:
parent
47da72bbee
commit
e59dacefa2
2 changed files with 7 additions and 2 deletions
|
|
@ -141,7 +141,7 @@ func (r *Request) Render() (string, int, error) {
|
|||
if c.Data != "" {
|
||||
err = r.Request.ExecStringMerge(data, c.Data)
|
||||
if err != nil {
|
||||
return "", 500, fmt.Errorf("data error, please re-complie the page. %s", err.Error())
|
||||
return "", 500, fmt.Errorf("data merge error, please re-complie the page. %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,7 +218,12 @@ func (r *Request) execValue(value interface{}) (interface{}, error) {
|
|||
}
|
||||
|
||||
if strings.HasPrefix(v, "$") {
|
||||
return r.call(strings.TrimLeft(v, "$"))
|
||||
res, err := r.call(strings.TrimLeft(v, "$"))
|
||||
if err != nil {
|
||||
log.Error("[Request] Exec value:%s, %s", v, err.Error())
|
||||
return nil, nil
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
return v, nil
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue