helper static method

String helper({
  1. int? errorType,
  2. Error? error,
})

Implementation

static String helper({int? errorType, Error? error}) {
  if (errorType == null && error == null) {
    return "";
  }
  String message = "Request failed, please try again later !";
  String type = "$errorType";
  if (errorType == null && error != null) {
    type = error is HttpError ? "${error.code}" : "${error.runtimeType}";
    message =
        error is HttpError ? error.message ?? message : error.toString();
    errorType ??= RuntimeTypeMapper[type];
  }
  switch (errorType) {
    case RESPONSE_FORMAT_ERROR:
      message = "Bad Response Format!";
      break;
    case MULTIFILE_NOT_FOUND:
      message = "Multipart file not found!";
      break;
    case BAD_GATEWAY:
      message = "Something wrong on Server!";
      break;
    case GATEWAY_TIMEOUT:
      message = "Request timed out, please checkout network connection!";
      break;
    case INTERNAL_SERVER_ERROR:
      message = "Internal Server Error!";
      break;
    case NOT_FOUND:
      message = "Bad Request uri not found!";
      break;
  }
  return "[Error:$type] $message";
}