8000 Attempt at better error reporting. · vitrivr/vitrivr-engine@8aecbef · GitHub
[go: up one dir, main page]

Skip to content

Commit

Permalink
Attempt at better error reporting.
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph Gasser <rg@pontius.ch>
  • Loading branch information
ppanopticon committed Aug 23, 2024
1 parent 7f276a2 commit 8aecbef
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import org.vitrivr.engine.core.model.mesh.texturemodel.Model3d
import org.vitrivr.engine.model3d.lwjglrender.render.RenderOptions
import org.vitrivr.engine.model3d.lwjglrender.window.WindowOptions
import java.awt.image.BufferedImage
import java.io.Closeable
import java.io.IOException
import java.io.ObjectInputStream
import java.io.ObjectOutputStream
import java.io.*
import kotlin.jvm.optionals.getOrNull

/**
Expand Down Expand Up @@ -81,18 +78,23 @@ class ExternalRenderer : Closeable {
/** The [ObjectInputStream] used by the [ExternalRenderer]. */
val ois: ObjectInputStream

/** The standard error */
val err: BufferedReader

init {
val javaBin = ProcessHandle.current().info().command().getOrNull() ?: throw IllegalStateException("Could not determine JAVA_HOME.")
val classpath = System.getProperty("java.class.path")
val processBuilder = ProcessBuilder(javaBin, "-cp", classpath, "-XstartOnFirstThread", CLASS_NAME)
this.process = processBuilder.start()

/* Initialize streams. */
if (this.process.isAlive) {
this.err = this.process.errorReader()
try {
this.oos = ObjectOutputStream(this.process.outputStream)
this.ois = ObjectInputStream(this.process.inputStream)
} else {
throw IllegalStateException("Failed to start external renderer.")
} catch (e: Throwable) {
val err = this.err.readText()
throw IllegalStateException("Failed to start external renderer due to error: $err", e)
}
}

Expand All @@ -115,6 +117,9 @@ class ExternalRenderer : Closeable {
} catch (e: IOException) {
this.ois.reset()
throw IllegalStateException("Could not parse model due to IO exception.", e)
} catch (e: IOException) {
this.ois.reset()
throw IllegalStateException("Could not parse model due to IO exception.", e)
}
return image
}
Expand Down

0 comments on commit 8aecbef

Please sign in to comment.
0