From 406506c63ee1b0932939aadf4481ebab58fb8bb4 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 14 Jun 2023 12:29:15 +0200 Subject: [PATCH] rpc: document errors.Is(..., ErrNotificationsUnsupported) better --- rpc/subscription.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rpc/subscription.go b/rpc/subscription.go index e10dfe8169ccc..3231c2ceec9b5 100644 --- a/rpc/subscription.go +++ b/rpc/subscription.go @@ -32,7 +32,15 @@ import ( ) var ( - // ErrNotificationsUnsupported is returned when the connection doesn't support notifications + // ErrNotificationsUnsupported is returned by the client when the connection doesn't + // support notifications. You can use this error value to check for subscription + // support like this: + // + // sub, err := client.EthSubscribe(ctx, channel, "newHeads", true) + // if errors.Is(err, rpc.ErrNotificationsUnsupported) { + // // Server does not support subscriptions, fall back to polling. + // } + // ErrNotificationsUnsupported = notificationsUnsupportedError{} // ErrSubscriptionNotFound is returned when the notification for the given id is not found