use of org.ballerinalang.bre.bvm.CallableUnitCallback in project ballerina by ballerina-lang.
the class ReadCharacters method readCharactersResponse.
/*
* Callback method of the read characters response.
*
* @param result the result returned as the response.
* @return the processed event result.
*/
private static EventResult readCharactersResponse(EventResult<String, EventContext> result) {
BStruct errorStruct = null;
EventContext eventContext = result.getContext();
Context context = eventContext.getContext();
CallableUnitCallback callback = eventContext.getCallback();
String readChars = result.getResponse();
Throwable error = eventContext.getError();
if (null != error) {
errorStruct = IOUtils.createError(context, error.getMessage());
context.setReturnValues(errorStruct);
} else {
context.setReturnValues(new BString(readChars));
}
callback.notifySuccess();
return result;
}
Aggregations