fix: Log errors to console if no onError
handler is passed
This commit is contained in:
parent
c9dbd412be
commit
98a641702c
@ -380,13 +380,16 @@ export class Camera extends React.PureComponent<CameraProps> {
|
|||||||
|
|
||||||
//#region Events (Wrapped to maintain reference equality)
|
//#region Events (Wrapped to maintain reference equality)
|
||||||
private onError(event: NativeSyntheticEvent<OnErrorEvent>): void {
|
private onError(event: NativeSyntheticEvent<OnErrorEvent>): void {
|
||||||
|
const error = event.nativeEvent
|
||||||
|
const cause = isErrorWithCause(error.cause) ? error.cause : undefined
|
||||||
|
// @ts-expect-error We're casting from unknown bridge types to TS unions, I expect it to hopefully work
|
||||||
|
const cameraError = new CameraRuntimeError(error.code, error.message, cause)
|
||||||
|
|
||||||
if (this.props.onError != null) {
|
if (this.props.onError != null) {
|
||||||
const error = event.nativeEvent
|
this.props.onError(cameraError)
|
||||||
const cause = isErrorWithCause(error.cause) ? error.cause : undefined
|
} else {
|
||||||
this.props.onError(
|
// User didn't pass an `onError` handler, so just log it to console
|
||||||
// @ts-expect-error We're casting from unknown bridge types to TS unions, I expect it to hopefully work
|
console.error(`Camera.onError(${cameraError.code}): ${cameraError.message}`, cameraError)
|
||||||
new CameraRuntimeError(error.code, error.message, cause),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user