             return
         #else
             if currentlyAuthorized(forMediaType: mediaType) {
-                completion?(.success(createCaptureDevice(mediaType)))
+                guard let device = createCaptureDevice(mediaType) else {
+                    completion?(.failure(creationError(mediaType: mediaType)))
+                    return
+                }
+                completion?(.success(device))
                 return
             }
 

        return AVCaptureDevice.default(for: mediaType.stringConstant())
    }

}


            }

            guard let device = createCaptureDevice(mediaType) else {
                completion?(.failure(creationError(mediaType: mediaType)))
                return
            }

