simplify unmarshal (#191)

* simplify unmarshal

* simplify unmarshalError

* rename errorAccumulate -> defaultErrorAccumulator

* update converage
This commit is contained in:
sashabaranov
2023-03-22 09:56:05 +04:00
committed by GitHub
parent a5a945ad14
commit eb68a72bcc
3 changed files with 29 additions and 22 deletions

View File

@@ -33,8 +33,9 @@ func (stream *streamReader[T]) Recv() (response T, err error) {
waitForData:
line, err := stream.reader.ReadBytes('\n')
if err != nil {
if errRes, _ := stream.errAccumulator.unmarshalError(); errRes != nil {
err = fmt.Errorf("error, %w", errRes.Error)
respErr := stream.errAccumulator.unmarshalError()
if respErr != nil {
err = fmt.Errorf("error, %w", respErr.Error)
}
return
}