dioErrorHandle method

Map<String, dynamic> dioErrorHandle({
  1. DioError? error,
  2. String? stringError,
})

Implementation

Map<String, dynamic> dioErrorHandle({DioError? error, String? stringError}) {
  if (error != null) {
    log(
      error.toString(),
      name: "ERROR",
    );
  } else {
    log(
      stringError!,
      name: "ERROR",
    );
  }
  if (error != null) {
    switch (error.type) {
      case DioErrorType.response:
        {
          log(error.response.toString());

          return {
            "error": {"message": "something went wrong"}
          };
        }
      default:
        {
          return {
            "error": {"message": "something went wrong"}
          };
        }
    }
  } else {
    return {
      "error": {"message": stringError}
    };
  }
}