AOSSIE-Org / AOSSIE-Org/Resonate

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

Đang mở
#680 3 bình luận 0 reaction 1 người được giao Được @YadavAkhileshh nhận Xem trên GitHub
enhancement good first issue
Ngôn ngữ chính
Dart
Star
344
Fork
350
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.