From 8abeef4b25b97fdefa26c788aa3c29ee31c9f1fb Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Thu, 4 Mar 2021 12:04:39 +0100 Subject: [PATCH] Update Errors/Formats docs --- docs/docs/ERRORS.md | 9 +++++++-- docs/docs/FORMATS.md | 6 +++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/docs/ERRORS.md b/docs/docs/ERRORS.md index 478952e..5674595 100644 --- a/docs/docs/ERRORS.md +++ b/docs/docs/ERRORS.md @@ -10,7 +10,7 @@ sidebar_label: Camera Errors ## Why? -Since the Camera library is quite big, there is a lot that can "go wrong". The react-native-vision-camera library provides thoroughly typed errors to help you quickly identify the cause and fix the problem. +Since the Camera library is quite big, there is a lot that can "go wrong". The VisionCamera library provides thoroughly typed errors to help you quickly identify the cause and fix the problem. ```ts switch (error.code) { @@ -47,6 +47,10 @@ The `CameraError` type is a baseclass type for all other errors and provides the * `cause.stacktrace?`: A native Java stacktrace for the cause. (Android only) * `cause.cause?`: The cause that caused this cause. (Recursive) (Optional) +:::note +See [the `CameraError.ts` file](https://github.com/cuvent/react-native-vision-camera/blob/main/src/CameraError.ts) for a list of all possible error codes +::: + ### Runtime Errors The `CameraRuntimeError` represents any kind of error that occured while mounting the Camera view, or an error that occured during the runtime. @@ -59,7 +63,7 @@ function App() { console.error(error) }, []) - return + return } ``` @@ -71,6 +75,7 @@ The `CameraCaptureError` represents any kind of error that occured only while ca function App() { const camera = useRef(null) + // called when the user presses a "capture" button const onPress = useCallback(() => { try { const photo = await camera.current.takePhoto() diff --git a/docs/docs/FORMATS.md b/docs/docs/FORMATS.md index afdc232..de06664 100644 --- a/docs/docs/FORMATS.md +++ b/docs/docs/FORMATS.md @@ -16,7 +16,7 @@ Each camera device (see [Camera Devices](./DEVICES.md)) provides a number of cap If you don't want to specify the best format for your camera device, you don't have to. The Camera _automatically chooses the best matching format_ for the current camera device. This is why the Camera's `format` property is _optional_. -If you don't want to do a lot of filtering, but still want to let the camera know what your intentions are, you can use the Camera's `preset` property. (See the [CameraPreset.ts](https://github.com/cuvent/react-native-vision-camera/blob/main/src/CameraPreset.ts) type for more information about presets) +If you don't want to do a lot of filtering, but still want to let the camera know what your intentions are, you can use the Camera's `preset` property. For example, use the `'medium'` preset if you want to create a video-chat application that shouldn't excessively use mobile data: @@ -36,6 +36,10 @@ function App() { } ``` +:::note +See the [CameraPreset.ts](https://github.com/cuvent/react-native-vision-camera/blob/main/src/CameraPreset.ts) type for more information about presets +::: + ### What you need to know about cameras To understand a bit more about camera formats, you first need to understand a few "general camera basics":