Skip to content

Commit a9c01a9

Browse files
feat: add new PlatformNotSupported error
1 parent 7753bd1 commit a9c01a9

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

packages/react-native-executorch/common/rnexecutorch/ErrorCodes.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ enum class RnExecutorchErrorCode : int32_t {
7575
* interruptions.
7676
*/
7777
DownloadInterrupted = 118,
78+
/**
79+
* Thrown when a feature or platform is not supported in the current
80+
* environment.
81+
*/
82+
PlatformNotSupported = 119,
7883
/**
7984
* Thrown when an error occurs with the tokenizer or tokenization process.
8085
*/

packages/react-native-executorch/common/rnexecutorch/utils/FrameExtractor.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cv::Mat extractFromCVPixelBuffer(void *pixelBuffer) {
4343
char errorMessage[100];
4444
std::snprintf(errorMessage, sizeof(errorMessage),
4545
"Unsupported CVPixelBuffer format: %u", pixelFormat);
46-
throw RnExecutorchError(RnExecutorchErrorCode::InvalidUserInput,
46+
throw RnExecutorchError(RnExecutorchErrorCode::PlatformNotSupported,
4747
errorMessage);
4848
}
4949

@@ -84,14 +84,15 @@ cv::Mat extractFromAHardwareBuffer(void *hardwareBuffer) {
8484
char errorMessage[100];
8585
std::snprintf(errorMessage, sizeof(errorMessage),
8686
"Unsupported AHardwareBuffer format: %u", desc.format);
87-
throw RnExecutorchError(RnExecutorchErrorCode::UnknownError, errorMessage);
87+
throw RnExecutorchError(RnExecutorchErrorCode::PlatformNotSupported,
88+
errorMessage);
8889
}
8990

9091
// Note: We don't unlock here - Vision Camera manages the lifecycle
9192

9293
return mat;
9394
#else
94-
throw RnExecutorchError(RnExecutorchErrorCode::UnknownError,
95+
throw RnExecutorchError(RnExecutorchErrorCode::PlatformNotSupported,
9596
"AHardwareBuffer requires Android API 26+");
9697
#endif // __ANDROID_API__ >= 26
9798
}
@@ -105,7 +106,7 @@ cv::Mat extractFromNativeBuffer(uint64_t bufferPtr) {
105106
#elif defined(__ANDROID__)
106107
return extractFromAHardwareBuffer(reinterpret_cast<void *>(bufferPtr));
107108
#else
108-
throw RnExecutorchError(RnExecutorchErrorCode::UnknownError,
109+
throw RnExecutorchError(RnExecutorchErrorCode::PlatformNotSupported,
109110
"NativeBuffer not supported on this platform");
110111
#endif
111112
}

packages/react-native-executorch/src/errors/ErrorCodes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ export enum RnExecutorchErrorCode {
5858
* Thrown when the number of downloaded files is unexpected, due to download interruptions.
5959
*/
6060
DownloadInterrupted = 118,
61+
/**
62+
* Thrown when a feature or platform is not supported in the current environment.
63+
*/
64+
PlatformNotSupported = 119,
6165
/**
6266
* Thrown when an error occurs with the tokenizer or tokenization process.
6367
*/

scripts/errors.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export const errorDefinitions = {
5959
* Thrown when the number of downloaded files is unexpected, due to download interruptions.
6060
*/
6161
DownloadInterrupted: 0x76,
62+
/*
63+
* Thrown when a feature or platform is not supported in the current environment.
64+
*/
65+
PlatformNotSupported: 0x77,
6266

6367
/*
6468
* Thrown when an error occurs with the tokenizer or tokenization process.

0 commit comments

Comments
 (0)