handleErrorComing static method

String handleErrorComing(
  1. DioError error
)

Implementation

static String handleErrorComing(DioError error) {
  String errorDescription = "";
  if (error is DioError) {
    switch (error.type) {
      case DioErrorType.cancel:
        errorDescription = "Request to server was cancelled";
        break;
      case DioErrorType.connectTimeout:
        errorDescription = "Connection timeout. Please try again!.";
        break;
      case DioErrorType.other:
        errorDescription =
            "Connection to server failed due to internet connection";
        break;
      case DioErrorType.receiveTimeout:
        errorDescription = "Receive timeout in connection with server";
        break;
      case DioErrorType.response:
        errorDescription = "${error.response?.data['message']}";
        break;
      case DioErrorType.sendTimeout:
        errorDescription = "Send timeout in connection with server";
        break;
    }
  } else {
    errorDescription = "Unexpected error occured";
  }
  return errorDescription;
}