saveErrorReport method

Future<void> saveErrorReport(
  1. Map<String, String> errors,
  2. String outputPath
)

Implementation

Future<void> saveErrorReport(
  Map<String, String> errors,
  String outputPath,
) async {
  try {
    final directory = Directory(path_util.dirname(outputPath));
    if (!await directory.exists()) {
      await directory.create(recursive: true);
    }

    final file = File(outputPath);
    final report = {
      'timestamp': DateTime.now().toIso8601String(),
      'totalErrors': errors.length,
      'errors': errors.map((path, error) => MapEntry(path, {
            'path': path,
            'error': error,
          })),
    };

    await file.writeAsString(
      JsonEncoder.withIndent('  ').convert(report),
    );
  } catch (e) {
    throw AssetOptException('Failed to save error report: $e');
  }
}