diff --git a/write/csvToProtocolLines.go b/write/csvToProtocolLines.go index 8b72de8868..4076fa7ff1 100644 --- a/write/csvToProtocolLines.go +++ b/write/csvToProtocolLines.go @@ -15,12 +15,7 @@ type CsvLineError struct { } func (e CsvLineError) Error() string { - switch err := e.Err.(type) { - case CsvColumnError: - return fmt.Sprintf("line %d, column '%s': %v", e.Line, err.Column, err) - default: - return fmt.Sprintf("line %d: %v", e.Line, e.Err) - } + return fmt.Sprintf("line %d: %v", e.Line, e.Err) } type lineReader struct { diff --git a/write/csvToProtocolLines_test.go b/write/csvToProtocolLines_test.go index 08f387fdad..4f72595e96 100644 --- a/write/csvToProtocolLines_test.go +++ b/write/csvToProtocolLines_test.go @@ -1,6 +1,7 @@ package write import ( + "errors" "io" "strings" "testing" @@ -75,3 +76,23 @@ func Test_CsvToProtocolLines_success(t *testing.T) { } } } + +// Test_CsvLineError checks formating of line errors +func Test_CsvLineError(t *testing.T) { + var tests = []struct { + err CsvLineError + value string + }{ + { + CsvLineError{Line: 1, Err: errors.New("cause")}, + "line 1: cause", + }, + { + CsvLineError{Line: 2, Err: CsvColumnError{"a", errors.New("cause")}}, + "line 2: column 'a': cause", + }, + } + for _, test := range tests { + require.Equal(t, test.value, test.err.Error()) + } +} diff --git a/write/dataConversion.go b/write/dataConversion.go index 0327e2b0e1..22311f1ec2 100644 --- a/write/dataConversion.go +++ b/write/dataConversion.go @@ -112,7 +112,7 @@ func toTypedValue(val string, dataType string) (interface{}, error) { case base64BinaryDataType: return base64.StdEncoding.DecodeString(val) default: - return nil, fmt.Errorf("value '%s' has unsupported data type '%s'", val, dataType) + return nil, fmt.Errorf("unsupported data type '%s'", dataType) } }