use of co.aurasphere.botmill.fb.model.incoming.FacebookError in project fb-botmill by BotMill.
the class FbBotMillNetworkController method propagateResponse.
/**
* Propagates the response to the registered {@link FbBotMillMonitor}.
*
* @param response
* the response to propagate.
*/
private static void propagateResponse(BotMillNetworkResponse response) {
String output = response.getResponse();
if (response.isError()) {
// Parses the error message and logs it.
FacebookErrorMessage errorMessage = FbBotMillJsonUtils.fromJson(output, FacebookErrorMessage.class);
FacebookError error = errorMessage.getError();
logger.error("Error message from Facebook. Message: [{}], Code: [{}], Type: [{}], FbTraceID: [{}].", error.getMessage(), error.getCode(), error.getType(), error.getFbTraceId());
// Sends the callback to the registered network monitors.
for (FbBotMillMonitor monitor : registeredMonitors) {
monitor.onError(errorMessage);
}
} else {
FacebookConfirmationMessage confirmationMessage = FbBotMillJsonUtils.fromJson(output, FacebookConfirmationMessage.class);
logger.debug("Confirmation from Facebook. Recipient ID: [{}], Message ID: [{}], Result Message: [{}]", confirmationMessage.getRecipientId(), confirmationMessage.getMessageId(), confirmationMessage.getResult());
// Sends the callback to the registered network monitors.
for (FbBotMillMonitor monitor : registeredMonitors) {
monitor.onConfirmation(confirmationMessage);
}
}
}
Aggregations