Skip to content

Commit

Permalink
Rename Field to FieldID
Browse files Browse the repository at this point in the history
  • Loading branch information
meparle committed Nov 30, 2023
1 parent f042288 commit d6c0ac9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package iso8583
// connection failed to unpack message
type UnpackError struct {
Err error
Field string
FieldID string
RawMessage []byte
}

Expand Down
8 changes: 4 additions & 4 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
Expand All @@ -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,
}
}
Expand All @@ -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,
}
}
Expand All @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d6c0ac9

Please sign in to comment.