Closed tlukkezen closed 1 year ago
What about files that have wrong file extensions but are otherwise correct, such as example.gef.bak
?
Maybe another option is to pass an optional flag specifying the type:
read_cpt("example.gef.bak", file_format = FileFormat.GEF)
Where file_format
can be FileFormat.GEF
, FileFormat.XML
or FileFormat.Auto
.
If the user provides a file to
read_cpt
that is neither in the correct .gef or .xml format, pygef tries to read as an xml and throws confusing exceptions.Specifically, if a user provides a .gef file with erroneous format, the user gets BroXMLParser exceptions, which makes no sense.
Expected result The user should get an insightful exception (e.g. custom UnknownFileFormatException) that explains that the provided file cannot be parsed as a .gef or .xml