{
// The existence of a throwable indicates that something went wrong
if (reply.getThrowable() != null)
{
Throwable ex = reply.getThrowable();
ScriptBuffer script = EnginePrivate.getRemoteHandleExceptionScript(batchId, callId, ex);
conduit.addScript(script);
// TODO: Are there any reasons why we should be logging here (and in the ConversionException handler)
//log.warn("--Erroring: batchId[" + batchId + "] message[" + ex.toString() + ']'), ex;
}
else
{
Object data = reply.getReply();
ScriptBuffer script = EnginePrivate.getRemoteHandleCallbackScript(batchId, callId, data);
conduit.addScript(script);
}
}
catch (IOException ex)
{
// We're a bit stuck we died half way through writing so
// we can't be sure the browser can react to the failure.
// Since we can no longer do output we just log and end
log.error("--Output Error: batchId[" + batchId + "] message[" + ex.toString() + ']', ex);
}
catch (ConversionException ex)
{
ScriptBuffer script = EnginePrivate.getRemoteHandleExceptionScript(batchId, callId, ex);
addScriptHandleExceptions(conduit, script);
log.warn("--ConversionException: batchId=" + batchId + " class=" + ex.getConversionType().getName(), ex);
}
catch (Exception ex)
{
// This is a bit of a "this can't happen" case so I am a bit
// nervous about sending the exception to the client, but we
// want to avoid silently dying so we need to do something.
ScriptBuffer script = EnginePrivate.getRemoteHandleExceptionScript(batchId, callId, ex);
addScriptHandleExceptions(conduit, script);
log.error("--ConversionException: batchId=" + batchId + " message=" + ex.toString());
}
}
sendOutboundScriptSuffix(out, replies.getCalls().getInstanceId(), replies.getCalls().getBatchId());