Skip to content

Commit c64cc9a

Browse files
committed
ReportMetaDataLookup throws error for incorrect file
With this change, if the metadata file has an incorrect value for "dispositions" or "reportType", the module will throw an error on startup. Previously, it would replace the incorrect value with a placeholder value, which is not what we want.
1 parent 90082da commit c64cc9a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

publication/src/main/scala/hmda/publication/reports/util/ReportsMetadataLookup.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package hmda.publication.reports.util
33
import com.github.tototoshi.csv.CSVParser.parse
44
import hmda.model.ResourceUtils
55
import hmda.model.publication.reports.ReportTypeEnum
6-
import hmda.model.publication.reports.ReportTypeEnum.Disclosure
7-
import hmda.publication.reports.util.DispositionType.{ DispositionType, ReceivedDisp }
6+
import hmda.publication.reports.util.DispositionType.DispositionType
87

98
object ReportsMetaDataLookup extends ResourceUtils {
109

@@ -30,12 +29,12 @@ case object ReportMetaData {
3029
def fromString(line: String): ReportMetaData = {
3130
val values = parse(line, '\\', ',', '"').getOrElse(List())
3231
val reportId = values.head
33-
val reportType = ReportTypeEnum.byName.getOrElse(values(1).toLowerCase, Disclosure)
32+
val reportType = ReportTypeEnum.byName(values(1).toLowerCase)
3433
val reportNumber = values(2)
3534
val description = values(4)
3635
val dispositions =
3736
values(3).split(";").filter(_.nonEmpty).map { d =>
38-
DispositionType.byName.getOrElse(d.toLowerCase, ReceivedDisp)
37+
DispositionType.byName(d.toLowerCase)
3938
}.toList
4039

4140
ReportMetaData(

0 commit comments

Comments
 (0)