public static String getErrorMessage()

in app/src/main/java/org/apache/fineract/utils/MifosErrorUtils.java [39:76]


    public static String getErrorMessage(Context context, Throwable throwable) {
        MifosError mifosError = new MifosError();
        Converter<ResponseBody, MifosError> errorConverter =
                retrofit.responseBodyConverter(MifosError.class, new Annotation[0]);

        if (throwable instanceof IOException) {
            return NETWORK_ERROR_MESSAGE;
        }

        if (throwable instanceof HttpException) {
            HttpException httpException = (HttpException) throwable;
            int code = httpException.code();
            Response response = httpException.response();

            if (response.errorBody() != null) {
                try {
                    mifosError = errorConverter.convert(response.errorBody());
                } catch (IOException e) {
                    Log.d(LOG_TAG, e.getLocalizedMessage());
                }
            }

            switch (code) {
                case 400:
                    return mifosError.getMessage();
                case 403:
                    //access token has expired
                    break;
                case 404:
                    //you don't have permission
                    return mifosError.getMessage();
                case 409:
                    //resource already exists
                    break;
            }
        }
        return mifosError.getMessage();
    }