AOSSIE-Org / AOSSIE-Org/Resonate

`refactor: Replace print() statement with proper logging in whisper_transcription_controller`

Aperta
#680 3 commenti 0 reazioni 1 assegnatario Rivendicata da @YadavAkhileshh Vedi su GitHub
enhancement good first issue
Lingua principale
Dart
Stelle
344
Fork
350
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## Description
The `whisper_transcription_controller.dart` file has two logging/error handling issues:
1. Line 71: Using `print()` instead of proper logging
2. Lines 62-73: Generic error handling without context or stack trace

## Current Issues

### Issue 1: Using print() instead of log()
```dart
} catch (e) {
print(e.toString());
}
```

### Issue 2: Poor error handling in loop (Lines 62-73)
```dart
for (WhisperTranscribeSegment? segment in transcriptionSegments) {
try {
final segmentString = _parseTranscriptionSegment(segment);
if (segmentString != null) {
lrcContent.writeln(segmentString);
}
} catch (e) {
print(e.toString()); // No context, no stack trace
}
}
```

## Problems
1. Using `print()` instead of `log()` (file already imports `dart:developer`)
2. Inconsistent logging (rest of file uses `log()`)
3. No context about which segment failed
4. No stack trace for debugging
5. Silently continues without proper error reporting

## Proposed Solution

### Fix 1: Replace print() with log()
```dart
} catch (e) {
log('Error converting transcription segment: ${e.toString()}');
}
```

### Fix 2: Improve error handling with context
```dart
for (int i = 0; i < transcriptionSegments.length; i++) {
try {
final segment = transcriptionSegments[i];
final segmentString = _parseTranscriptionSegment(segment);
if (segmentString != null) {
lrcContent.writeln(segmentString);
}
} catch (e, stackTrace) {
log(
'Error converting transcription segment at index $i: ${e.toString()}',
error: e,
stackTrace: stackTrace,
);
......
}
}
```

## Benefits
- Consistent logging throughout the file
- Better debugging with segment index
- Proper stack traces for error diagnosis
- Follows Flutter best practices
- More maintainable code

## Files to Change
- `lib/controllers/whisper_transcription_controller.dart` (2 locations)

## I would like to work on this

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.