File tree Expand file tree Collapse file tree
packages/camera/camera_platform_interface Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## 2.1.5
2+
3+ * Fixes asynchronous exceptions handling of the ` initializeCamera ` method.
4+
15## 2.1.4
26
37* Removes dependency on ` meta ` .
Original file line number Diff line number Diff line change @@ -126,6 +126,16 @@ class MethodChannelCamera extends CameraPlatform {
126126 'cameraId' : cameraId,
127127 'imageFormatGroup' : imageFormatGroup.name (),
128128 },
129+ ).catchError (
130+ (Object error, StackTrace stackTrace) {
131+ if (error is ! PlatformException ) {
132+ throw error;
133+ }
134+ _completer.completeError (
135+ CameraException (error.code, error.message),
136+ stackTrace,
137+ );
138+ },
129139 );
130140
131141 return _completer.future;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_
44issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7- version : 2.1.4
7+ version : 2.1.5
88
99environment :
1010 sdk : ' >=2.12.0 <3.0.0'
Original file line number Diff line number Diff line change @@ -126,6 +126,38 @@ void main() {
126126 );
127127 });
128128
129+ test (
130+ 'Should throw CameraException when initialize throws a PlatformException' ,
131+ () {
132+ // Arrange
133+ MethodChannelMock (
134+ channelName: 'plugins.flutter.io/camera' ,
135+ methods: < String , dynamic > {
136+ 'initialize' : PlatformException (
137+ code: 'TESTING_ERROR_CODE' ,
138+ message: 'Mock error message used during testing.' ,
139+ )
140+ },
141+ );
142+ final MethodChannelCamera camera = MethodChannelCamera ();
143+
144+ // Act
145+ expect (
146+ () => camera.initializeCamera (0 ),
147+ throwsA (
148+ isA <CameraException >()
149+ .having ((CameraException e) => e.code, 'code' ,
150+ 'TESTING_ERROR_CODE' )
151+ .having (
152+ (CameraException e) => e.description,
153+ 'description' ,
154+ 'Mock error message used during testing.' ,
155+ ),
156+ ),
157+ );
158+ },
159+ );
160+
129161 test ('Should send initialization data' , () async {
130162 // Arrange
131163 final MethodChannelMock cameraMockChannel = MethodChannelMock (
You can’t perform that action at this time.
0 commit comments