scaffoldExceptionMapper method

Future<void> scaffoldExceptionMapper(
  1. String projectPath
)

Implementation

Future<void> scaffoldExceptionMapper(String projectPath) async {
  final baseDir = projectPath.endsWith('/')
      ? projectPath.substring(0, projectPath.length - 1)
      : projectPath;

  final file = File('$baseDir/lib/core/exceptions/exception_mapper.dart');
  if (!await file.exists()) {
    await file.parent.create(recursive: true);
    await file.writeAsString('''
import 'app_exception.dart';

// Responsibility:
// Maps exceptions to standard AppExceptions.

class ExceptionMapper {
static AppException map(dynamic exception) {
  return UnknownException(exception.toString());
}
}
''');
  }
}