Skip to content

Commit

Permalink
Removal of unused onExceptionalCallback (#7970)
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach authored Oct 4, 2023
1 parent c525698 commit aada58e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ public interface Callbacks {
* result.
*/
Object onFunctionReturn(UUID nodeId, FunctionCallInstrumentationNode.FunctionCall result);

/** Notification on an exception.
* @param e the reported exception
*/
void onExceptionalCallback(Exception e);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
private final Consumer<ExpressionValue> onCachedCallback;
private final Consumer<ExpressionValue> onComputedCallback;
private final Consumer<ExpressionCall> functionCallCallback;
private final Consumer<Exception> onExceptionalCallback;

/** Creates callbacks instance.
*
Expand All @@ -43,13 +42,12 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
* @param functionCallCallback the consumer of function call events.
* @param onComputedCallback the consumer of the computed value events.
* @param onCachedCallback the consumer of the cached value events.
* @param onExceptionalCallback the consumer of the exceptional events.
*/
ExecutionCallbacks(
UUID nextExecutionItem,
RuntimeCache cache, MethodCallsCache methodCallsCache, UpdatesSynchronizationState syncState,
Consumer<ExpressionValue> onCachedCallback, Consumer<ExpressionValue> onComputedCallback,
Consumer<ExpressionCall> functionCallCallback, Consumer<Exception> onExceptionalCallback
Consumer<ExpressionCall> functionCallCallback
) {
this.nextExecutionItem = nextExecutionItem;
this.cache = cache;
Expand All @@ -58,7 +56,6 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
this.onCachedCallback = onCachedCallback;
this.onComputedCallback = onComputedCallback;
this.functionCallCallback = functionCallCallback;
this.onExceptionalCallback = onExceptionalCallback;
}

@CompilerDirectives.TruffleBoundary
Expand Down Expand Up @@ -130,12 +127,6 @@ public final Object onFunctionReturn(UUID nodeId, FunctionCallInstrumentationNod
return null;
}

@CompilerDirectives.TruffleBoundary
@Override
public final void onExceptionalCallback(Exception e) {
onExceptionalCallback.accept(e);
}

@CompilerDirectives.TruffleBoundary
private void passExpressionValueToCallback(ExpressionValue expressionValue) {
onComputedCallback.accept(expressionValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,15 @@ public void execute(
UUID nextExecutionItem,
Consumer<IdExecutionService.ExpressionCall> funCallCallback,
Consumer<IdExecutionService.ExpressionValue> onComputedCallback,
Consumer<IdExecutionService.ExpressionValue> onCachedCallback,
Consumer<Exception> onExceptionalCallback)
throws ArityException, SourceNotFoundException, UnsupportedMessageException,
UnsupportedTypeException {
Consumer<IdExecutionService.ExpressionValue> onCachedCallback
) throws ArityException, SourceNotFoundException, UnsupportedMessageException, UnsupportedTypeException {
SourceSection src = call.getFunction().getSourceSection();
if (src == null) {
throw new SourceNotFoundException(call.getFunction().getName());
}
var callbacks = new ExecutionCallbacks(
nextExecutionItem, cache, methodCallsCache, syncState,
onCachedCallback, onComputedCallback, funCallCallback, onExceptionalCallback
onCachedCallback, onComputedCallback, funCallCallback
);
Optional<EventBinding<ExecutionEventNodeFactory>> eventNodeFactory =
idExecutionInstrument.map(service -> service.bind(
Expand Down Expand Up @@ -196,7 +194,6 @@ public void execute(
* @param funCallCallback the consumer for function call events.
* @param onComputedCallback the consumer of the computed value events.
* @param onCachedCallback the consumer of the cached value events.
* @param onExceptionalCallback the consumer of the exceptional events.
*/
public void execute(
String moduleName,
Expand All @@ -208,8 +205,8 @@ public void execute(
UUID nextExecutionItem,
Consumer<IdExecutionService.ExpressionCall> funCallCallback,
Consumer<IdExecutionService.ExpressionValue> onComputedCallback,
Consumer<IdExecutionService.ExpressionValue> onCachedCallback,
Consumer<Exception> onExceptionalCallback)
Consumer<IdExecutionService.ExpressionValue> onCachedCallback
)
throws ArityException, TypeNotFoundException, MethodNotFoundException,
ModuleNotFoundException, UnsupportedMessageException, UnsupportedTypeException {
Module module =
Expand All @@ -225,8 +222,8 @@ public void execute(
nextExecutionItem,
funCallCallback,
onComputedCallback,
onCachedCallback,
onExceptionalCallback);
onCachedCallback
);
}

/**
Expand Down Expand Up @@ -307,7 +304,7 @@ public Object callFunctionWithInstrument(

var callbacks = new ExecutionCallbacks(
nextExecutionItem, cache, methodCallsCache, syncState,
onCachedCallback, onComputedCallback, funCallCallback, onExceptionalCallback
onCachedCallback, onComputedCallback, funCallCallback
);
Optional<EventBinding<ExecutionEventNodeFactory>> eventNodeFactory =
idExecutionInstrument.map(service -> service.bind(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ object ProgramExecutionSupport {
}
}

val onExceptionalCallback: Consumer[Exception] = { value =>
logger.log(Level.FINEST, s"ON_ERROR $value")
sendErrorUpdate(contextId, value)
}

val callablesCallback: Consumer[ExpressionCall] = fun =>
if (callStack.headOption.exists(_.expressionId == fun.getExpressionId)) {
enterables += fun.getExpressionId -> fun.getCall
Expand All @@ -107,8 +102,7 @@ object ProgramExecutionSupport {
callStack.headOption.map(_.expressionId).orNull,
callablesCallback,
onComputedValueCallback,
onCachedValueCallback,
onExceptionalCallback
onCachedValueCallback
)
case ExecutionFrame(
ExecutionItem.CallData(expressionId, callData),
Expand All @@ -130,8 +124,7 @@ object ProgramExecutionSupport {
callStack.headOption.map(_.expressionId).orNull,
callablesCallback,
onComputedValueCallback,
onCachedValueCallback,
onExceptionalCallback
onCachedValueCallback
)
}

Expand Down Expand Up @@ -306,25 +299,6 @@ object ProgramExecutionSupport {
Api.ExecutionResult.Failure(ex.getMessage, None)
}

private def sendErrorUpdate(contextId: ContextId, error: Exception)(implicit
ctx: RuntimeContext
): Unit = {
ctx.endpoint.sendToClient(
Api.Response(
Api.ExecutionUpdate(
contextId,
Seq(
getDiagnosticOutcome.applyOrElse(
error,
(ex: Exception) =>
Api.ExecutionResult.Diagnostic.error(ex.getMessage)
)
)
)
)
)
}

private def sendExpressionUpdate(
contextId: ContextId,
syncState: UpdatesSynchronizationState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.enso.interpreter.runtime.Module;
import org.enso.interpreter.runtime.callable.function.Function;
import org.enso.interpreter.runtime.control.TailCallException;
import org.enso.interpreter.runtime.data.text.Text;
import org.enso.interpreter.runtime.error.DataflowError;
import org.enso.interpreter.runtime.error.PanicException;
import org.enso.interpreter.runtime.error.PanicSentinel;
Expand Down Expand Up @@ -184,7 +185,7 @@ private void onTailCallReturn(Throwable exception, State state) {
Object result = InteropLibrary.getFactory().getUncached().execute(functionCall);
onReturnValue(null, result);
} catch (InteropException e) {
callbacks.onExceptionalCallback(e);
throw new PanicException(Text.create(e.getMessage()), this);
}
}

Expand Down

0 comments on commit aada58e

Please sign in to comment.