diff --git a/nwaku.go b/nwaku.go index 084c4c1..a99e412 100644 --- a/nwaku.go +++ b/nwaku.go @@ -31,7 +31,7 @@ func main() { var contentTopic = "/toy-chat/2/huilong/proto" // Get node info - var wakuInfo = nwaku.GetWakuDebugInfo(client) + var wakuInfo, _ = nwaku.GetWakuDebugInfo(client) fmt.Println("WakuInfo ListenStr", wakuInfo.ListenStr) // Query messages diff --git a/nwaku/jsonrpc.go b/nwaku/jsonrpc.go index 00fe3f9..d45f0eb 100644 --- a/nwaku/jsonrpc.go +++ b/nwaku/jsonrpc.go @@ -4,14 +4,14 @@ import ( "github.com/ethereum/go-ethereum/rpc" ) -func GetWakuDebugInfo(client *rpc.Client) WakuInfo { +func GetWakuDebugInfo(client *rpc.Client) (WakuInfo, error) { var wakuInfo WakuInfo if err := client.Call(&wakuInfo, "get_waku_v2_debug_v1_info"); err != nil { - panic(err) + return wakuInfo, err } - return wakuInfo + return wakuInfo, nil } func GetWakuStoreMessages(client *rpc.Client, contentTopic string) (StoreResponse, error) { @@ -66,4 +66,3 @@ func GetWakuRelayMessages(client *rpc.Client, topic string) ([]WakuMessage, erro // - Exposing higher level methods as API // - Consider using methods scoped to rpc.Client instead // - Support more args in store rpc call -// - Uniform error handling