diff --git a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala index ef6b458db8d1..70b3ebecea10 100644 --- a/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala +++ b/engine/runtime/src/main/scala/org/enso/interpreter/instrument/job/ProgramExecutionSupport.scala @@ -37,7 +37,7 @@ import org.enso.interpreter.service.error.{ import org.enso.polyglot.LanguageInfo import org.enso.polyglot.runtime.Runtime.Api import org.enso.polyglot.runtime.Runtime.Api.ContextId -import org.enso.interpreter.runtime.error.PanicSentinel +import org.enso.interpreter.runtime.error.{DataflowError, PanicSentinel} import scala.jdk.OptionConverters._ @@ -331,6 +331,10 @@ trait ProgramExecutionSupport { sentinel.getMessage, ErrorResolver.getStackTrace(sentinel).flatMap(_.expressionId) ) + case error: DataflowError => + Api.ExpressionUpdate.Payload.DataflowError( + ErrorResolver.getStackTrace(error).flatMap(_.expressionId) + ) case _ => Api.ExpressionUpdate.Payload.Value() } diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ExpressionErrorsTest.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ExpressionErrorsTest.scala index 9bde30f46c1d..f7dc288adb05 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ExpressionErrorsTest.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/ExpressionErrorsTest.scala @@ -392,10 +392,26 @@ class ExpressionErrorsTest ) context.receive(6) should contain theSameElementsAs Seq( Api.Response(requestId, Api.PushContextResponse(contextId)), - TestMessages.update(contextId, xId, Constants.ERROR), - TestMessages.update(contextId, fooBodyId, Constants.ERROR), - TestMessages.update(contextId, yId, Constants.ERROR), - TestMessages.update(contextId, mainResId, Constants.ERROR), + TestMessages.error( + contextId, + xId, + Api.ExpressionUpdate.Payload.DataflowError(Seq()) + ), + TestMessages.error( + contextId, + fooBodyId, + Api.ExpressionUpdate.Payload.DataflowError(Seq()) + ), + TestMessages.error( + contextId, + yId, + Api.ExpressionUpdate.Payload.DataflowError(Seq()) + ), + TestMessages.error( + contextId, + mainResId, + Api.ExpressionUpdate.Payload.DataflowError(Seq()) + ), context.executionComplete(contextId) ) } @@ -543,7 +559,11 @@ class ExpressionErrorsTest ) ) ), - TestMessages.update(contextId, xId, Constants.ERROR), + TestMessages.error( + contextId, + xId, + Api.ExpressionUpdate.Payload.DataflowError(Seq()) + ), TestMessages.update(contextId, yId, Constants.INTEGER), TestMessages.update(contextId, mainResId, Constants.NOTHING), context.executionComplete(contextId) diff --git a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/TestMessages.scala b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/TestMessages.scala index 43aa1a9d14f8..7d6d3d05f7b5 100644 --- a/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/TestMessages.scala +++ b/engine/runtime/src/test/scala/org/enso/interpreter/test/instrument/TestMessages.scala @@ -2,6 +2,7 @@ package org.enso.interpreter.test.instrument import java.util.UUID +import org.enso.interpreter.runtime.`type`.Constants import org.enso.polyglot.runtime.Runtime.Api /** Helper methods for creating test messages. */ @@ -109,4 +110,105 @@ object TestMessages { ) ) ) + + /** Create an error update response. + * + * @param contextId an identifier of the context + * @param expressionId an identifier of the expression + * @param payload the error payload + * @return the expression update response + */ + def error( + contextId: UUID, + expressionId: UUID, + payload: Api.ExpressionUpdate.Payload + ): Api.Response = + error(contextId, expressionId, Constants.ERROR, payload) + + /** Create an error update response. + * + * @param contextId an identifier of the context + * @param expressionId an identifier of the expression + * @param expressionType a type of the expression + * @param payload the error payload + * @return the expression update response + */ + def error( + contextId: UUID, + expressionId: UUID, + expressionType: String, + payload: Api.ExpressionUpdate.Payload + ): Api.Response = + errorBuilder( + contextId, + expressionId, + Some(expressionType), + None, + false, + payload + ) + + /** Create an error update response. + * + * @param contextId an identifier of the context + * @param expressionId an identifier of the expression + * @param expressionType a type of the expression + * @param methodPointer a pointer to the method definition + * @param fromCache whether or not the value for this expression came + * from the cache + * @param payload the error payload + * @return the expression update response + */ + def error( + contextId: UUID, + expressionId: UUID, + expressionType: String, + methodPointer: Api.MethodPointer, + fromCache: Boolean, + payload: Api.ExpressionUpdate.Payload + ): Api.Response = + errorBuilder( + contextId, + expressionId, + Some(expressionType), + Some(methodPointer), + fromCache, + payload + ) + + /** Create an error update response. + * + * @param contextId an identifier of the context + * @param expressionId an identifier of the expression + * @param expressionTypeOpt a type of the expression + * @param methodPointerOpt a pointer to the method definition + * @param fromCache whether or not the value for this expression came + * from the cache + * @param payload the error payload + * @return the expression update response + */ + private def errorBuilder( + contextId: UUID, + expressionId: UUID, + expressionTypeOpt: Option[String], + methodPointerOpt: Option[Api.MethodPointer], + fromCache: Boolean, + payload: Api.ExpressionUpdate.Payload + ): Api.Response = + Api.Response( + Api.ExpressionUpdates( + contextId, + Set( + Api.ExpressionUpdate( + expressionId, + expressionTypeOpt, + methodPointerOpt, + Vector(Api.ProfilingInfo.ExecutionTime(0)), + fromCache, + payload + ) + ) + ) + ) + }