1 /* 2 * Copyright 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.camera.core; 18 19 import org.jspecify.annotations.NonNull; 20 import org.jspecify.annotations.Nullable; 21 22 /** 23 * An exception thrown to indicate an error has occurred during image capture or while saving the 24 * captured image. See {@link ImageCapture.OnImageCapturedCallback} and 25 * {@link ImageCapture.OnImageSavedCallback}. 26 */ 27 public class ImageCaptureException extends Exception { 28 29 @ImageCapture.ImageCaptureError 30 private final int mImageCaptureError; 31 ImageCaptureException(@mageCapture.ImageCaptureError final int imageCaptureError, final @NonNull String message, final @Nullable Throwable cause)32 public ImageCaptureException(@ImageCapture.ImageCaptureError final int imageCaptureError, 33 final @NonNull String message, final @Nullable Throwable cause) { 34 super(message, cause); 35 mImageCaptureError = imageCaptureError; 36 } 37 38 /** 39 * Returns the type of the image capture error. 40 * 41 * @return The image capture error type, can have one of the following values: 42 * {@link ImageCapture#ERROR_UNKNOWN}, {@link ImageCapture#ERROR_FILE_IO}, 43 * {@link ImageCapture#ERROR_CAPTURE_FAILED}, {@link ImageCapture#ERROR_CAMERA_CLOSED}, 44 * {@link ImageCapture#ERROR_INVALID_CAMERA}. 45 */ 46 @ImageCapture.ImageCaptureError getImageCaptureError()47 public int getImageCaptureError() { 48 return mImageCaptureError; 49 } 50 } 51