Skip to content

Commit a649fc7

Browse files
committed
[dev] let call() catch panic if in need
This packcage should not break user's application.
1 parent 938ae2f commit a649fc7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ func (c *Client) call(module, action string, param map[string]interface{}, outco
6262
defer c.AfterRequest(module, action, param, outcome, err)
6363
}
6464

65+
// recover if there shall be an panic
66+
defer func() {
67+
if r := recover(); r != nil {
68+
err = fmt.Errorf("[ouch! panic recovered] please report this with what you did and what you expected, panic detail: %v", r)
69+
}
70+
}()
71+
6572
req, err := http.NewRequest(http.MethodGet, c.craftURL(module, action, param), http.NoBody)
6673
if err != nil {
6774
err = wrapErr(err, "http.NewRequest")

0 commit comments

Comments
 (0)