readEnvelopeFile throws exception instead of returning null for missing encoders

This commit is contained in:
Alexander Nozik 2021-01-28 10:25:54 +03:00
parent 25cba0c6de
commit e88178ffe7
2 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@ plugins {
id("ru.mipt.npm.project")
}
val dataforgeVersion by extra("0.3.0-dev-1")
val dataforgeVersion by extra("0.3.0-dev-2")
val bintrayRepo by extra("dataforge")
val githubProject by extra("dataforge-core")

View File

@ -152,8 +152,8 @@ public fun IOPlugin.readEnvelopeFile(
path: Path,
readNonEnvelopes: Boolean = false,
formatPicker: IOPlugin.(Path) -> EnvelopeFormat? = IOPlugin::peekFileEnvelopeFormat,
): Envelope? {
if (!Files.exists(path)) return null
): Envelope {
if (!Files.exists(path)) error("File with path $path does not exist")
//read two-files directory
if (Files.isDirectory(path)) {
@ -182,7 +182,7 @@ public fun IOPlugin.readEnvelopeFile(
path.readEnvelope(format)
} ?: if (readNonEnvelopes) { // if no format accepts file, read it as binary
SimpleEnvelope(Meta.EMPTY, path.asBinary())
} else null
} else error("Can't infer format for file $path")
}
/**