package com.atmob.voiceai.helper;

import androidx.annotation.StringRes;

import com.atmob.app.lib.handler.RxHttpHandler;
import com.atmob.voiceai.R;
import com.atmob.voiceai.utils.ToastUtil;

public class ErrorHelper {

    public static void errorThrowableToast(Throwable throwable, @ToastUtil.Duration int duration) {
        if (throwable instanceof RxHttpHandler.ServerErrorException) {
            RxHttpHandler.ServerErrorException serverErrorException = (RxHttpHandler.ServerErrorException) throwable;
            errorToast(serverErrorException.getCode(), duration);
        } else {
            ToastUtil.show(R.string.net_error_message, duration);
        }
    }

    public static void errorToast(int errorCode, @ToastUtil.Duration int duration) {
        ToastUtil.show(getErrorResId(errorCode), duration);
    }

    @StringRes
    public static int getErrorResId(int errorCode) {
        int errorResId = R.string.net_error_message;
        switch (errorCode) {

        }
        return errorResId;
    }
}
