getHycopException static method

HycopException getHycopException({
  1. dynamic error,
  2. required String defaultMessage,
  3. int? code,
})

Implementation

static HycopException getHycopException({
  dynamic error,
  required String defaultMessage,
  int? code,
}) {
  String defMsg;
  if (error is HycopException) {
    return error;
  } else if (error is FirebaseException) {
    FirebaseException ex = error;
    defMsg = '${ex.message} (${ex.code}:$defaultMessage)';
  } else if (error is Exception) {
    Exception ex = error;
    defMsg = '$defaultMessage (${ex.toString()})'; //ex.toString();
  } else {
    defMsg = defaultMessage;
  }
  return HycopException(
    message: defMsg,
    exception: (error is Exception) ? error : Exception(error.toString()),
    code: code,
  );
}