Skip to content

Commit 11abcbe

Browse files
authored
feat: add CameraErrorCode enum for type-safe error handling (#45)
1 parent a7df43c commit 11abcbe

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

src/definitions.ts

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,3 +865,146 @@ export type CameraPhoto = Photo;
865865
* @since 1.0.0
866866
*/
867867
export type CameraOptions = ImageOptions;
868+
869+
/**
870+
* Error codes returned by the Camera plugin.
871+
* These values match the `code` field on rejected promises.
872+
*
873+
* @since 8.2.0
874+
*/
875+
export enum CameraErrorCode {
876+
// Permissions
877+
/**
878+
* Camera access was denied by the user.
879+
*/
880+
CameraPermissionDenied = 'OS-PLUG-CAMR-0003',
881+
882+
/**
883+
* Photo library / gallery access was denied by the user.
884+
*/
885+
GalleryPermissionDenied = 'OS-PLUG-CAMR-0005',
886+
887+
/**
888+
* No camera hardware is available on the device.
889+
*/
890+
NoCameraAvailable = 'OS-PLUG-CAMR-0007',
891+
892+
// Take Photo
893+
/**
894+
* The user cancelled the take photo action.
895+
*/
896+
TakePhotoCancelled = 'OS-PLUG-CAMR-0006',
897+
898+
/**
899+
* Failed to take photo.
900+
*/
901+
TakePhotoFailed = 'OS-PLUG-CAMR-0010',
902+
903+
/**
904+
* The take photo action received invalid arguments.
905+
* @platform ios
906+
*/
907+
TakePhotoInvalidArguments = 'OS-PLUG-CAMR-0014',
908+
909+
// Edit Photo
910+
/**
911+
* The selected file contains invalid image data.
912+
* @platform ios
913+
*/
914+
InvalidImageData = 'OS-PLUG-CAMR-0008',
915+
916+
/**
917+
* Failed to edit image.
918+
*/
919+
EditPhotoFailed = 'OS-PLUG-CAMR-0009',
920+
921+
/**
922+
* The user cancelled the edit photo action.
923+
*/
924+
EditPhotoCancelled = 'OS-PLUG-CAMR-0013',
925+
926+
/**
927+
* The URI parameter for editing is empty.
928+
* @platform android
929+
*/
930+
EditPhotoEmptyUri = 'OS-PLUG-CAMR-0024',
931+
932+
// Choose from Gallery
933+
/**
934+
* Failed to retrieve an image from the gallery.
935+
*/
936+
ImageNotFound = 'OS-PLUG-CAMR-0011',
937+
938+
/**
939+
* Failed to process the selected image.
940+
*/
941+
ProcessImageFailed = 'OS-PLUG-CAMR-0012',
942+
943+
/**
944+
* Failed to choose media from the gallery.
945+
*/
946+
ChooseMediaFailed = 'OS-PLUG-CAMR-0018',
947+
948+
/**
949+
* The user cancelled choosing media from the gallery.
950+
*/
951+
ChooseMediaCancelled = 'OS-PLUG-CAMR-0020',
952+
953+
/**
954+
* Failed to retrieve the media file path.
955+
* @platform android
956+
*/
957+
MediaPathError = 'OS-PLUG-CAMR-0021',
958+
959+
/**
960+
* Failed to retrieve an image from the provided URI.
961+
*/
962+
FetchImageFromUriFailed = 'OS-PLUG-CAMR-0028',
963+
964+
// Record Video
965+
/**
966+
* Failed to record video.
967+
*/
968+
RecordVideoFailed = 'OS-PLUG-CAMR-0016',
969+
970+
/**
971+
* The user cancelled the video recording.
972+
*/
973+
RecordVideoCancelled = 'OS-PLUG-CAMR-0017',
974+
975+
/**
976+
* Failed to retrieve a video from the gallery.
977+
* @platform ios
978+
*/
979+
VideoNotFound = 'OS-PLUG-CAMR-0025',
980+
981+
// Play Video
982+
/**
983+
* Failed to play video.
984+
*/
985+
PlayVideoFailed = 'OS-PLUG-CAMR-0023',
986+
987+
// General
988+
/**
989+
* Failed to encode the media result.
990+
* @platform ios
991+
*/
992+
EncodeResultFailed = 'OS-PLUG-CAMR-0019',
993+
994+
/**
995+
* The selected file does not exist.
996+
*/
997+
FileNotFound = 'OS-PLUG-CAMR-0027',
998+
999+
/**
1000+
* Invalid argument provided to a plugin method.
1001+
* @platform android
1002+
*/
1003+
InvalidArgument = 'OS-PLUG-CAMR-0031',
1004+
1005+
/**
1006+
* A general plugin error occurred.
1007+
* @platform ios
1008+
*/
1009+
GeneralError = 'OS-PLUG-CAMR-0026',
1010+
}

0 commit comments

Comments
 (0)