func readInitialStreamError(ws base.Stream) error {
	// We can use bufio here because the websocket guarantees that a
	// single read will not read more than a single frame; there is
	// no guarantee that a single read might not read less than the
	// whole frame though, so using a single Read call is not
	// correct. By using ReadSlice rather than ReadBytes, we
	// guarantee that the error can't be too big (>4096 bytes).
	messageType, reader, err := ws.NextReader()
	if err != nil {
		return errors.Annotate(err, "unable to get reader")
	}
	if messageType != websocket.TextMessage {
		return errors.Errorf("unexpected message type %v", messageType)
	}
	line, err := bufio.NewReader(reader).ReadSlice('\n')
	if err != nil {
		return errors.Annotate(err, "unable to read initial response")
	}
	var errResult params.ErrorResult
	if err := json.Unmarshal(line, &errResult); err != nil {
		return errors.Annotate(err, "unable to unmarshal initial response")
	}
	if errResult.Error != nil {
		return errResult.Error
	}
	return nil
}
// readInitialStreamError reads the initial error response
// from a stream connection and returns it.
readInitialStreamError reads the initial error response
from a stream connection and returns it.
// readInitialStreamError reads the initial error response // from a stream connection and returns it .
func readInitialStreamError(ws base.Stream) error {
	messageType, reader, err := ws.NextReader()
	if err != nil {
		return errors.Annotate(err, "unable to get reader")
	}
	if messageType != websocket.TextMessage {
		return errors.Errorf("unexpected message type %v", messageType)
	}
	line, err := bufio.NewReader(reader).ReadSlice('\n')
	if err != nil {
		return errors.Annotate(err, "unable to read initial response")
	}
	var errResult params.ErrorResult
	if err := json.Unmarshal(line, &errResult); err != nil {
		return errors.Annotate(err, "unable to unmarshal initial response")
	}
	if errResult.Error != nil {
		return errResult.Error
	}
	return nil
}
func readInitialStreamError ( ws base . Stream ) error { messageType , reader , err := ws . NextReader ( ) if err != nil { return errors . Annotate ( err , " " ) } if messageType != websocket . TextMessage { return errors . Errorf ( " " , messageType ) } line , err := bufio . NewReader ( reader ) . ReadSlice ( '\n' ) if err != nil { return errors . Annotate ( err , " " ) } var errResult params . ErrorResult if err := json . Unmarshal ( line , & errResult ) ; err != nil { return errors . Annotate ( err , " " ) } if errResult . Error != nil { return errResult . Error } return nil }
readInitialStreamError reads the initial error response
from a stream connection and returns it.
readInitialStreamError reads the initial error response from a stream connection and returns it .
// We can use bufio here because the websocket guarantees that a // single read will not read more than a single frame; there is // no guarantee that a single read might not read less than the // whole frame though, so using a single Read call is not // correct. By using ReadSlice rather than ReadBytes, we // guarantee that the error can't be too big (>4096 bytes).