Skip to content

Commit

Permalink
add new error class for barcode errors
Browse files Browse the repository at this point in the history
  • Loading branch information
navaronbracke committed Jun 18, 2024
1 parent 89e056c commit 67f7e8f
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions lib/src/mobile_scanner_exception.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:mobile_scanner/src/enums/mobile_scanner_error_code.dart';

/// This class represents an exception thrown by the mobile scanner.
/// This class represents an exception thrown by the [MobileScannerController].
class MobileScannerException implements Exception {
const MobileScannerException({
required this.errorCode,
Expand All @@ -16,9 +16,9 @@ class MobileScannerException implements Exception {
@override
String toString() {
if (errorDetails != null && errorDetails?.message != null) {
return "MobileScannerException: code ${errorCode.name}, message: ${errorDetails?.message}";
return 'MobileScannerException: code ${errorCode.name}, message: ${errorDetails?.message}';
}
return "MobileScannerException: ${errorCode.name}";
return 'MobileScannerException: ${errorCode.name}';
}
}

Expand All @@ -39,3 +39,22 @@ class MobileScannerErrorDetails {
/// The error message from the [PlatformException].
final String? message;
}

/// This class represents an exception thrown by the [MobileScannerController]
/// when a barcode scanning error occurs when processing an input frame.
class MobileScannerBarcodeException implements Exception {
/// Creates a new [MobileScannerBarcodeException] with the given error message.
const MobileScannerBarcodeException(this.message);

/// The error message of the exception.
final String? message;

@override
String toString() {
if (message?.isNotEmpty ?? false) {
return 'MobileScannerBarcodeException: $message';
}

return 'MobileScannerBarcodeException: Could not detect a barcode in the input image.';
}
}

0 comments on commit 67f7e8f

Please sign in to comment.