Dont break grib parsing on corrupted data
This commit is contained in:
@@ -17,10 +17,14 @@ object GribParser {
|
|||||||
result <- if (ptr >= fileSize) {
|
result <- if (ptr >= fileSize) {
|
||||||
IO.pure(acc.reverse)
|
IO.pure(acc.reverse)
|
||||||
} else {
|
} else {
|
||||||
for {
|
parseGrib(path, ptr).attempt.flatMap {
|
||||||
grib <- parseGrib(path, ptr)
|
case Right(grib) =>
|
||||||
nextResult <- loop(ptr + grib.length, grib :: acc)
|
loop(ptr + grib.length, grib :: acc)
|
||||||
} yield nextResult
|
case Left(error) =>
|
||||||
|
// Just log the error and end parsing
|
||||||
|
IO(println(s"Error parsing GRIB at position $ptr: ${error.getMessage}")) >>
|
||||||
|
IO.pure(acc.reverse)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} yield result
|
} yield result
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user