diff --git a/errors.go b/errors.go index f6a74fe..b0643eb 100644 --- a/errors.go +++ b/errors.go @@ -4,7 +4,7 @@ package iso8583 // connection failed to unpack message type UnpackError struct { Err error - Field string + FieldID string RawMessage []byte } diff --git a/message.go b/message.go index 32d5667..25b78a9 100644 --- a/message.go +++ b/message.go @@ -249,7 +249,7 @@ func (m *Message) unpack(src []byte) error { if err != nil { return &UnpackError{ Err: fmt.Errorf("failed to unpack MTI: %w", err), - Field: strconv.Itoa(mtiIdx), + FieldID: strconv.Itoa(mtiIdx), RawMessage: src, } } @@ -263,7 +263,7 @@ func (m *Message) unpack(src []byte) error { if err != nil { return &UnpackError{ Err: fmt.Errorf("failed to unpack bitmap: %w", err), - Field: strconv.Itoa(bitmapIdx), + FieldID: strconv.Itoa(bitmapIdx), RawMessage: src, } } @@ -281,7 +281,7 @@ func (m *Message) unpack(src []byte) error { if !ok { return &UnpackError{ Err: fmt.Errorf("failed to unpack field %d: no specification found", i), - Field: strconv.Itoa(i), + FieldID: strconv.Itoa(i), RawMessage: src, } } @@ -290,7 +290,7 @@ func (m *Message) unpack(src []byte) error { if err != nil { return &UnpackError{ Err: fmt.Errorf("failed to unpack field %d (%s): %w", i, fl.Spec().Description, err), - Field: strconv.Itoa(i), + FieldID: strconv.Itoa(i), RawMessage: src, } } diff --git a/message_test.go b/message_test.go index 7ada7d3..9e7170b 100644 --- a/message_test.go +++ b/message_test.go @@ -762,7 +762,7 @@ func TestPackUnpack(t *testing.T) { require.Error(t, err) var unpackError *UnpackError require.ErrorAs(t, err, &unpackError) - assert.Equal(t, unpackError.Field, "120") + assert.Equal(t, unpackError.FieldID, "120") s, err := message.GetString(2) require.NoError(t, err)