From 224888c4a33e36798c851899be1be4db37d1b929 Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Wed, 18 Dec 2019 17:23:51 -0500 Subject: [PATCH] address feedback re nil s --- developing-with-nats/receiving/structure.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/developing-with-nats/receiving/structure.md b/developing-with-nats/receiving/structure.md index 6a7a430..5be208c 100644 --- a/developing-with-nats/receiving/structure.md +++ b/developing-with-nats/receiving/structure.md @@ -9,7 +9,11 @@ For example, to receive JSON you could do: ```go nc, err := nats.Connect("demo.nats.io", nats.ErrorHandler(func(nc *nats.Conn, s *nats.Subscription, err error) { - log.Printf("Async error in %q/%q: %v", s.Subject, s.Queue, err) + if s != nil { + log.Printf("Async error in %q/%q: %v", s.Subject, s.Queue, err) + } else { + log.Printf("Async error outside subscription: %v", err) + } })) if err != nil { log.Fatal(err)