call method

  1. @override
Future<bool> call(
  1. String errorName,
  2. String path
)
override

Implementation

@override
Future<bool> call(String errorName, String path) async {
  var isValidDirectory = await Directory(path).exists();

  if (isValidDirectory) {
    var existFile =
        await File('$path/${ReCase(errorName).snakeCase}_error.dart')
            .exists();

    if (existFile) {
      throw FileExistsError(innerException: Exception());
    }

    File('$path/${ReCase(errorName).snakeCase}_error.dart')
        .createSync(recursive: true);
    var content = errorTemplate(errorName);

    File('$path/${ReCase(errorName).snakeCase}_error.dart')
        .writeAsStringSync(content);
    return true;
  } else {
    return false;
  }
}