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") 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 bintrayRepo by extra("dataforge")
val githubProject by extra("dataforge-core") val githubProject by extra("dataforge-core")

View File

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