Skip to content

Commit 86d9d17

Browse files
committed
Log all failures in Future
1 parent f413554 commit 86d9d17

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

bridge/src/main/scala/protocbridge/frontend/PluginFrontend.scala

+10-8
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ object PluginFrontend {
4747
gen: ProtocCodeGenerator,
4848
request: Array[Byte]
4949
): Array[Byte] = {
50-
Try {
51-
gen.run(request)
52-
}.recover { case throwable =>
53-
createCodeGeneratorResponseWithError(
54-
throwable.toString + "\n" + getStackTrace(throwable)
55-
)
56-
}.get
50+
gen.run(request)
5751
}
5852

5953
def createCodeGeneratorResponseWithError(error: String): Array[Byte] = {
@@ -116,9 +110,17 @@ object PluginFrontend {
116110
gen: ProtocCodeGenerator,
117111
fsin: InputStream,
118112
env: ExtraEnv
119-
): Array[Byte] = {
113+
): Array[Byte] = try {
114+
System.err.println("readInputStreamToByteArrayWithEnv...")
120115
val bytes = readInputStreamToByteArrayWithEnv(fsin, env)
116+
System.err.println("runWithBytes...")
121117
runWithBytes(gen, bytes)
118+
} catch {
119+
case throwable: Throwable =>
120+
System.err.println("createCodeGeneratorResponseWithError...")
121+
createCodeGeneratorResponseWithError(
122+
throwable.toString + "\n" + getStackTrace(throwable)
123+
)
122124
}
123125

124126
def createTempFile(extension: String, content: String): Path = {

bridge/src/main/scala/protocbridge/frontend/PosixPluginFrontend.scala

+8
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,21 @@ object PosixPluginFrontend extends PluginFrontend {
3636

3737
Future {
3838
blocking {
39+
System.err.println("Files.newInputStream...")
3940
val fsin = Files.newInputStream(inputPipe)
41+
System.err.println("PluginFrontend.runWithInputStream...")
4042
val response = PluginFrontend.runWithInputStream(plugin, fsin, env)
43+
System.err.println("fsin.close...")
4144
fsin.close()
4245

46+
System.err.println("Files.newOutputStream...")
4347
val fsout = Files.newOutputStream(outputPipe)
48+
System.err.println("fsout.write...")
4449
fsout.write(response)
50+
System.err.println("fsout.close...")
4551
fsout.close()
52+
53+
System.err.println("blocking done.")
4654
}
4755
}
4856
(sh, InternalState(inputPipe, outputPipe, tempDirPath, sh))

0 commit comments

Comments
 (0)