streams.go
changeset 128 a5a00fad7a32
parent 122 50c7733ee886
child 130 c450bb73f59a
--- a/streams.go	Sun Apr 16 02:12:38 2017 +0200
+++ b/streams.go	Sun Apr 16 13:37:37 2017 +0200
@@ -41,7 +41,11 @@
 		return nil, ErrInvalidParameter
 	}
 
-	req := g.prepareRequest("streaming/"+streamName, rest.Get, params)
+	req, err := g.prepareRequest("streaming/"+streamName, rest.Get, params)
+	if err != nil {
+		return nil, fmt.Errorf("cannot build stream request: %s", err.Error())
+	}
+
 	reqObj, err := rest.BuildRequestObject(req)
 	if err != nil {
 		return nil, fmt.Errorf("cannot build stream request: %s", err.Error())
@@ -175,6 +179,10 @@
 // The 'doneCh' channel is closed if the connection is closed by the server.
 // Please note that this method launches a goroutine to listen to the events.
 func (g *Client) StreamListener(name, hashTag string, events chan<- StreamEvent, stopCh <-chan bool, doneCh chan<- bool) error {
+	if g == nil {
+		return fmt.Errorf("use of uninitialized gondole client")
+	}
+
 	resp, err := g.openStream(name, hashTag)
 	if err != nil {
 		return err