Refactor SUI core to handle backend script errors during page execution
This commit is contained in:
parent
602333bd02
commit
6bcede11d9
2 changed files with 12 additions and 4 deletions
|
|
@ -133,14 +133,14 @@ func (r *Request) Render() (string, int, error) {
|
||||||
if c.Data != "" {
|
if c.Data != "" {
|
||||||
err = r.Request.ExecStringMerge(data, c.Data)
|
err = r.Request.ExecStringMerge(data, c.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", 500, fmt.Errorf("data error, please re-complie the page %s", err.Error())
|
return "", 500, fmt.Errorf("data error, please re-complie the page. %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Global != "" {
|
if c.Global != "" {
|
||||||
global, err := r.Request.ExecString(c.Global)
|
global, err := r.Request.ExecString(c.Global)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", 500, fmt.Errorf("global data error, please re-complie the page %s", err.Error())
|
return "", 500, fmt.Errorf("global data error, please re-complie the page. %s", err.Error())
|
||||||
}
|
}
|
||||||
data["$global"] = global
|
data["$global"] = global
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,11 @@ func (r *Request) ExecString(data string) (Data, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r.Exec(res)
|
err = r.Exec(res)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,7 +292,11 @@ func (r *Request) call(p interface{}) (interface{}, error) {
|
||||||
// Call the backend script
|
// Call the backend script
|
||||||
if r.Script != nil && strings.HasPrefix(processName, "@") {
|
if r.Script != nil && strings.HasPrefix(processName, "@") {
|
||||||
method := processName[1:]
|
method := processName[1:]
|
||||||
return r.Script.Call(r, method, processArgs...)
|
v, err := r.Script.Call(r, method, processArgs...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("backend script %s %s, please check the script", method, err.Error())
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
process, err := process.Of(processName, processArgs...)
|
process, err := process.Of(processName, processArgs...)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue