Skip to content

Commit

Permalink
Mark description @nonnull
Browse files Browse the repository at this point in the history
  • Loading branch information
yaakovschectman committed Oct 15, 2024
1 parent ca3da1b commit 29a8842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,11 @@ public void onOpened(@NonNull CameraDevice device) {
cameraFeatures.getFocusPoint().checkIsSupported());
}
} catch (Exception e) {
String message = (e.getMessage() == null) ? e.getClass().getName() : e.getMessage();
if (BuildConfig.DEBUG) {
Log.i(TAG, "open | onOpened error: " + e.getMessage());
Log.i(TAG, "open | onOpened error: " + message);
}
dartMessenger.sendCameraErrorEvent(e.getMessage());
dartMessenger.sendCameraErrorEvent(message);
close();
}
}
Expand Down Expand Up @@ -792,7 +793,8 @@ private void lockAutoFocus() {
try {
captureSession.capture(previewRequestBuilder.build(), null, backgroundHandler);
} catch (CameraAccessException e) {
dartMessenger.sendCameraErrorEvent(e.getMessage());
String message = (e.getMessage() == null) ? "CameraAccessException" : e.getMessage();
dartMessenger.sendCameraErrorEvent(message);
}
}

Expand All @@ -815,7 +817,8 @@ void unlockAutoFocus() {

captureSession.capture(previewRequestBuilder.build(), null, backgroundHandler);
} catch (CameraAccessException e) {
dartMessenger.sendCameraErrorEvent(e.getMessage());
String message = (e.getMessage() == null) ? "CameraAccessException" : e.getMessage();
dartMessenger.sendCameraErrorEvent(message);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,14 @@ void sendCameraClosingEvent() {
handler.post(() -> eventApi.closed(new NoOpVoidResult()));
}

// TODO(schectman): Make `description` non-null, see
// https://github.com/flutter/flutter/issues/156729
/**
* Sends a message to the Flutter client informing that an error occurred while interacting with
* the camera.
*
* @param description contains details regarding the error that occurred.
*/
void sendCameraErrorEvent(@Nullable String description) {
String errorMessage = (description == null) ? "" : description;
handler.post(() -> eventApi.error(errorMessage, new NoOpVoidResult()));
void sendCameraErrorEvent(@NonNull String description) {
handler.post(() -> eventApi.error(description, new NoOpVoidResult()));
}

/**
Expand Down

0 comments on commit 29a8842

Please sign in to comment.