Update Errors/Formats docs
This commit is contained in:
parent
e6397531ed
commit
8abeef4b25
@ -10,7 +10,7 @@ sidebar_label: Camera Errors
|
|||||||
|
|
||||||
## Why?
|
## 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
|
```ts
|
||||||
switch (error.code) {
|
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.stacktrace?`: A native Java stacktrace for the cause. (Android only)
|
||||||
* `cause.cause?`: The cause that caused this cause. (Recursive) (Optional)
|
* `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
|
### Runtime Errors
|
||||||
|
|
||||||
The `CameraRuntimeError` represents any kind of error that occured while mounting the Camera view, or an error that occured during the runtime.
|
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)
|
console.error(error)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <Camera ref={camera} {...cameraProps} />
|
return <Camera onError={onError} {...cameraProps} />
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -71,6 +75,7 @@ The `CameraCaptureError` represents any kind of error that occured only while ca
|
|||||||
function App() {
|
function App() {
|
||||||
const camera = useRef<Camera>(null)
|
const camera = useRef<Camera>(null)
|
||||||
|
|
||||||
|
// called when the user presses a "capture" button
|
||||||
const onPress = useCallback(() => {
|
const onPress = useCallback(() => {
|
||||||
try {
|
try {
|
||||||
const photo = await camera.current.takePhoto()
|
const photo = await camera.current.takePhoto()
|
||||||
|
@ -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 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:
|
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
|
### 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":
|
To understand a bit more about camera formats, you first need to understand a few "general camera basics":
|
||||||
|
Loading…
Reference in New Issue
Block a user