@TruffleBoundary
static void exceptionEventForClientInstrument(EventBinding.Source<?> b, String eventName, Throwable t) {
assert !b.isLanguageBinding();
if (t instanceof ThreadDeath) {
throw (ThreadDeath) t;
}
final Object currentVm = AccessorInstrumentHandler.engineAccess().getCurrentVM();
if (b.getInstrumenter() instanceof EngineInstrumenter || (currentVm != null && AccessorInstrumentHandler.engineAccess().isInstrumentExceptionsAreThrown(currentVm))) {
throw sthrow(RuntimeException.class, t);
}
InstrumentClientInstrumenter instrumenter = (InstrumentClientInstrumenter) b.getInstrumenter();
Class<?> instrumentClass = instrumenter.getInstrumentClass();
String message = String.format("Event %s failed for instrument class %s and listener/factory %s.",
eventName, instrumentClass.getName(), b.getElement());
Exception exception = new Exception(message, t);
PrintStream stream = new PrintStream(instrumenter.getEnv().err());
exception.printStackTrace(stream);
}