Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #561 from MITLibraries/bugfix
Browse files Browse the repository at this point in the history
Handle no 008 field error
  • Loading branch information
hakbailey authored Jul 15, 2021
2 parents 3bbf9b7 + 9883a88 commit 4831ec9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/generator/marc.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@ func marcToRecord(fmlRecord fml.Record, rules []*record.Rule, languageCodes map[
return r, err
}

zeroZeroEight := fmlRecord.Filter("008")[0][0]
if zeroZeroEight != "" && len(zeroZeroEight) != 40 {
err = fmt.Errorf("Record %s has illegal 008 field length of %d characters: '%s'", r.Identifier, len(zeroZeroEight), zeroZeroEight)
zeroZeroEight := fmlRecord.Filter("008")
if len(zeroZeroEight) == 0 {
err = fmt.Errorf("Record %s has no 008 field", r.Identifier)
return r, err
}
if zeroZeroEight[0][0] != "" && len(zeroZeroEight[0][0]) != 40 {
err = fmt.Errorf("Record %s has illegal 008 field length of %d characters: '%s'", r.Identifier, len(zeroZeroEight[0][0]), zeroZeroEight[0][0])
return r, err
}

Expand Down

0 comments on commit 4831ec9

Please sign in to comment.