mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 22:10:15 +03:00
Don't NPE when Throwable is missing message (#11102)
Looks like `Throwable` thrown by the execution may be missing a message, which later crashes when we want to send it over the wire. Added some guards to prevent NPE.
This commit is contained in:
parent
3dd0fb95ae
commit
031300dfb3
@ -6,6 +6,8 @@ import org.enso.interpreter.instrument.execution.{Executable, RuntimeContext}
|
||||
import org.enso.interpreter.runtime.state.ExecutionEnvironment
|
||||
import org.enso.polyglot.runtime.Runtime.Api
|
||||
|
||||
import java.util.logging.Level
|
||||
|
||||
/** A job responsible for executing a call stack for the provided context.
|
||||
*
|
||||
* @param contextId an identifier of a context to execute
|
||||
@ -31,11 +33,25 @@ class ExecuteJob(
|
||||
runImpl
|
||||
} catch {
|
||||
case t: Throwable =>
|
||||
ctx.executionService.getLogger.log(Level.SEVERE, "Failed to execute", t)
|
||||
val errorMsg = if (t.getMessage == null) {
|
||||
if (t.getCause == null) {
|
||||
t.getClass.toString
|
||||
} else {
|
||||
val cause = t.getCause
|
||||
if (cause.getMessage == null) {
|
||||
cause.getClass.toString
|
||||
} else {
|
||||
cause.getMessage
|
||||
}
|
||||
}
|
||||
} else t.getMessage
|
||||
|
||||
ctx.endpoint.sendToClient(
|
||||
Api.Response(
|
||||
Api.ExecutionFailed(
|
||||
contextId,
|
||||
Api.ExecutionResult.Failure(t.getMessage, None)
|
||||
Api.ExecutionResult.Failure(errorMsg, None)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user