From fbbeb7b7e602c9f5911298667f04c9e9302a562a Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 6 Aug 2021 19:15:36 -0400 Subject: Add error handling --- src/utils/camera.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/utils/camera.ts b/src/utils/camera.ts index 5f02f653..6edc2b4f 100644 --- a/src/utils/camera.ts +++ b/src/utils/camera.ts @@ -30,9 +30,14 @@ export const takePicture = ( orientation: 'portrait', writeExif: false, }; - cameraRef.current?.takePictureAsync(options).then((pic) => { - callback(pic); - }); + cameraRef.current + ?.takePictureAsync(options) + .then((pic) => { + callback(pic); + }) + .catch((error) => { + console.log(error); + }); } }; @@ -46,9 +51,14 @@ export const takeVideo = ( maxDuration: MAX_VIDEO_RECORDING_DURATION, quality: '1080p', }; - cameraRef.current?.recordAsync(options).then((vid) => { - callback(vid); - }); + cameraRef.current + ?.recordAsync(options) + .then((vid) => { + callback(vid); + }) + .catch((error) => { + console.log(error); + }); } }; -- cgit v1.2.3-70-g09d2