Search in sources :

Example 1 with Error

use of com.fanap.podchat.model.Error in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method handleError.

private void handleError(ChatMessage chatMessage) {
    Error error = gson.fromJson(chatMessage.getContent(), Error.class);
    if (error.getCode() == 401) {
        pingHandler.removeCallbacksAndMessages(null);
    } else if (error.getCode() == 21) {
        userInfoResponse = true;
        retryStepUserInfo = 1;
        chatReady = false;
        tokenHandler.removeCallbacksAndMessages(null);
        String errorMessage = error.getMessage();
        long errorCode = error.getCode();
        captureError(errorMessage, errorCode, chatMessage.getUniqueId());
        pingHandler.removeCallbacksAndMessages(null);
        stopTyping();
        /*we are Changing the state of the chat because of the Client is not Authenticate*/
        listenerManager.callOnChatState("ASYNC_READY");
        return;
    }
    String errorMessage = error.getMessage();
    long errorCode = error.getCode();
    if (PodNotificationManager.isNotificationError(chatMessage, error, context, getUserId()))
        return;
    ThreadManager.onError(chatMessage);
    captureError(errorMessage, errorCode, chatMessage.getUniqueId());
}
Also used : Error(com.fanap.podchat.model.Error)

Example 2 with Error

use of com.fanap.podchat.model.Error in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method reformatError.

@NonNull
private String reformatError(boolean hasError, ChatMessage chatMessage, OutPutHistory outPut) {
    Error error = gson.fromJson(chatMessage.getContent(), Error.class);
    Log.e("RECEIVED_ERROR", chatMessage.getContent());
    Log.e("ErrorMessage", error.getMessage());
    Log.e("ErrorCode", String.valueOf(error.getCode()));
    outPut.setHasError(hasError);
    outPut.setErrorMessage(error.getMessage());
    outPut.setErrorCode(error.getCode());
    return gson.toJson(outPut);
}
Also used : Error(com.fanap.podchat.model.Error) NonNull(android.support.annotation.NonNull)

Aggregations

Error (com.fanap.podchat.model.Error)2 NonNull (android.support.annotation.NonNull)1