diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 983e99fb..d7fe074d 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -797,8 +797,8 @@ class Camera1 extends CameraController { return true; } catch (Exception e) { - // at least setParameters may fail. - // TODO why does it fail and is it possible to prevent such errors? + // at least getParameters and setParameters may fail. + // TODO why do they fail and is it possible to prevent such errors? CameraException cameraException = new CameraConfigurationFailedException("Failed to " + "start auto focus.", e); mCameraCallbacks.onError(cameraException); diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java index e59ad523..d767218e 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java @@ -1579,15 +1579,24 @@ public class CameraView extends FrameLayout { public void run() { // all error listeners will be called, but at most one of them should actually - // throw the exception + // throw an exception int count = 0; for (CameraListener listener : mListeners) { try { listener.onError(exception); } catch (CameraException ce) { - count++; + // if a custom error handler caused a new exception, we throw the new + // one instead of the original one + if (ce == exception) { + count++; + } + else { + throw ce; + } } } + + // the original exception is only thrown, if all existing listeners threw it if (count == mListeners.size()) { throw exception; }