Skip to content

Commit 5f959b6

Browse files
committed
fix MacOS leftover error codes
1 parent 2e1b5e8 commit 5f959b6

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

macos/mobile_scanner/Sources/mobile_scanner/MobileScannerPlugin.swift

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -465,20 +465,14 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
465465
let symbologies:[VNBarcodeSymbology] = argReader.toSymbology()
466466

467467
guard let filePath: String = argReader.string(key: "filePath") else {
468-
// TODO: fix error code
469-
result(FlutterError(code: "MobileScanner",
470-
message: "No image found in analyzeImage!",
471-
details: nil))
468+
result(nil)
472469
return
473470
}
474471

475472
let fileUrl = URL(fileURLWithPath: filePath)
476473

477474
guard let ciImage = CIImage(contentsOf: fileUrl) else {
478-
// TODO: fix error code
479-
result(FlutterError(code: "MobileScanner",
480-
message: "No image found in analyzeImage!",
481-
details: nil))
475+
result(nil)
482476
return
483477
}
484478

@@ -490,8 +484,9 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
490484

491485
if error != nil {
492486
DispatchQueue.main.async {
493-
// TODO: fix error code
494-
result(FlutterError(code: "MobileScanner", message: error?.localizedDescription, details: nil))
487+
result(FlutterError(
488+
code: MobileScannerErrorCodes.BARCODE_ERROR,
489+
message: error?.localizedDescription, details: nil))
495490
}
496491
return
497492
}
@@ -516,10 +511,11 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin, FlutterStreamHandler,
516511
}
517512

518513
try imageRequestHandler.perform([barcodeRequest])
519-
} catch let e {
520-
// TODO: fix error code
514+
} catch let error {
521515
DispatchQueue.main.async {
522-
result(FlutterError(code: "MobileScanner", message: e.localizedDescription, details: nil))
516+
result(FlutterError(
517+
code: MobileScannerErrorCodes.BARCODE_ERROR,
518+
message: error.localizedDescription, details: nil))
523519
}
524520
}
525521
}

0 commit comments

Comments
 (0)