Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no exception being raised on writer errors #158

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions error_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const (
// non specific.
kafkaForbiddenInInitContext errCode = 1000
noContextError errCode = 1001
contextCancelled errCode = 1002
cannotReportStats errCode = 1003
fileNotFound errCode = 1004
dialerError errCode = 1005
noTLSConfig errCode = 1006
failedTypeCast errCode = 1007
unsupportedOperation errCode = 1008
cannotReportStats errCode = 1002
fileNotFound errCode = 1003
dialerError errCode = 1004
noTLSConfig errCode = 1005
failedTypeCast errCode = 1006
unsupportedOperation errCode = 1007
writerError errCode = 1008

// serdes errors.
invalidDataType errCode = 2000
Expand Down
2 changes: 1 addition & 1 deletion reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (k *Kafka) reportReaderStats(currentStats kafkago.ReaderStats) {

ctx := k.vu.Context()
if ctx == nil {
err := NewXk6KafkaError(contextCancelled, "No context.", nil)
err := NewXk6KafkaError(noContextError, "No context.", nil)
logger.WithField("error", err).Info(err)
common.Throw(k.vu.Runtime(), err)
}
Expand Down
9 changes: 4 additions & 5 deletions writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package kafka
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -250,10 +249,10 @@ func (k *Kafka) produce(writer *kafkago.Writer, produceConfig *ProduceConfig) {

k.reportWriterStats(writer.Stats())

if originalErr != nil && errors.Is(originalErr, k.vu.Context().Err()) {
logger.WithField("error", k.vu.Context().Err()).Error(k.vu.Context().Err())
common.Throw(k.vu.Runtime(),
NewXk6KafkaError(contextCancelled, "Context cancelled.", originalErr))
if originalErr != nil {
err := NewXk6KafkaError(writerError, "Error writing messages.", originalErr)
logger.WithField("error", err).Error(err)
common.Throw(k.vu.Runtime(), err)
}
}

Expand Down