onError is called when an error happened in a method handler.
(err error)
| 1001 | |
| 1002 | // onError is called when an error happened in a method handler. |
| 1003 | func onError(err error) { |
| 1004 | // TODO do not marshal options again here |
| 1005 | switch e := err.(type) { |
| 1006 | case dnode.MethodNotFoundError: // Tell the requester "method is not found". |
| 1007 | args, err2 := e.Args.Slice() |
| 1008 | if err2 != nil { |
| 1009 | return |
| 1010 | } |
| 1011 | |
| 1012 | if len(args) < 1 { |
| 1013 | return |
| 1014 | } |
| 1015 | |
| 1016 | var options callOptions |
| 1017 | if err := args[0].Unmarshal(&options); err != nil { |
| 1018 | return |
| 1019 | } |
| 1020 | |
| 1021 | if options.ResponseCallback.Caller != nil { |
| 1022 | response := Response{ |
| 1023 | Result: nil, |
| 1024 | Error: &Error{ |
| 1025 | Type: "methodNotFound", |
| 1026 | Message: err.Error(), |
| 1027 | }, |
| 1028 | } |
| 1029 | options.ResponseCallback.Call(response) |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | type lockedBackoff struct { |
| 1035 | mu sync.Mutex |
no test coverage detected