Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/docs/05-utilities/04-error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,13 @@ These errors are mapped directly from the ExecuTorch runtime. They typically ind

#### System Errors

| Error Code | Description |
| -------------- | ----------------------------------- |
| `Ok` | Operation successful (not an error) |
| `Internal` | Internal ExecuTorch error |
| `InvalidState` | Operation called in invalid state |
| `EndOfMethod` | End of method reached |
| Error Code | Description |
| --------------- | ----------------------------------- |
| `Ok` | Operation successful (not an error) |
| `Internal` | Internal ExecuTorch error |
| `InvalidState` | Operation called in invalid state |
| `EndOfMethod` | End of method reached |
| `AlreadyLoaded` | Resource has already been loaded |

#### Logical Errors

Expand Down
20 changes: 10 additions & 10 deletions packages/react-native-executorch/common/rnexecutorch/ErrorCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ enum class RnExecutorchErrorCode : int32_t {
* when LLM's topp is outside of range [0, 1].
*/
InvalidConfig = 112,
/**
* Thrown when the type of model source passed by the user is invalid.
*/
InvalidModelSource = 255,
/**
* Thrown when the number of passed inputs to the model is different than the
* model metadata specifies.
*/
UnexpectedNumInputs = 97,
/**
* Thrown when React Native ExecuTorch threadpool problem occurs.
*/
Expand Down Expand Up @@ -80,10 +71,19 @@ enum class RnExecutorchErrorCode : int32_t {
* environment.
*/
PlatformNotSupported = 119,
/**
* Thrown when the type of model source passed by the user is invalid.
*/
InvalidModelSource = 120,
/**
* Thrown when the number of passed inputs to the model is different than the
* model metadata specifies.
*/
UnexpectedNumInputs = 121,
/**
* Thrown when an error occurs with the tokenizer or tokenization process.
*/
TokenizerError = 167,
TokenizerError = 122,
/**
* Thrown when there's a configuration mismatch between multilingual and
* language settings in Speech-to-Text models.
Expand Down
22 changes: 13 additions & 9 deletions packages/react-native-executorch/src/errors/ErrorCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ export enum RnExecutorchErrorCode {
* Thrown when config parameters passed to a model are invalid. For example, when LLM's topp is outside of range [0, 1].
*/
InvalidConfig = 112,
/**
* Thrown when the type of model source passed by the user is invalid.
*/
InvalidModelSource = 255,
/**
* Thrown when the number of passed inputs to the model is different than the model metadata specifies.
*/
UnexpectedNumInputs = 97,
/**
* Thrown when React Native ExecuTorch threadpool problem occurs.
*/
Expand Down Expand Up @@ -62,10 +54,18 @@ export enum RnExecutorchErrorCode {
* Thrown when a feature or platform is not supported in the current environment.
*/
PlatformNotSupported = 119,
/**
* Thrown when the type of model source passed by the user is invalid.
*/
InvalidModelSource = 120,
/**
* Thrown when the number of passed inputs to the model is different than the model metadata specifies.
*/
UnexpectedNumInputs = 121,
/**
* Thrown when an error occurs with the tokenizer or tokenization process.
*/
TokenizerError = 167,
TokenizerError = 122,
/**
* Thrown when there's a configuration mismatch between multilingual and language settings in Speech-to-Text models.
*/
Expand Down Expand Up @@ -130,6 +130,10 @@ export enum RnExecutorchErrorCode {
* Status indicating there are no more steps of execution to run
*/
EndOfMethod = 3,
/**
* Status indicating a resource has already been loaded.
*/
AlreadyLoaded = 4,
/**
* Operation is not supported in the current context.
*/
Expand Down
48 changes: 30 additions & 18 deletions scripts/errors.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Run `yarn codegen:errors` to generate C++ and TypeScript enums

export const errorDefinitions = {
// React-native-ExecuTorch errors
// =========================================================================
// General React Native ExecuTorch errors (0x60–0x7f)
// =========================================================================
/**
* An umbrella-error that is thrown usually when something unexpected happens, for example a 3rd-party library error.
*/
Expand All @@ -27,14 +29,6 @@ export const errorDefinitions = {
* Thrown when config parameters passed to a model are invalid. For example, when LLM's topp is outside of range [0, 1].
*/
InvalidConfig: 0x70,
/*
* Thrown when the type of model source passed by the user is invalid.
*/
InvalidModelSource: 0xff,
/*
* Thrown when the number of passed inputs to the model is different than the model metadata specifies.
*/
UnexpectedNumInputs: 0x61,
/*
* Thrown when React Native ExecuTorch threadpool problem occurs.
*/
Expand Down Expand Up @@ -63,12 +57,22 @@ export const errorDefinitions = {
* Thrown when a feature or platform is not supported in the current environment.
*/
PlatformNotSupported: 0x77,

/*
* Thrown when the type of model source passed by the user is invalid.
*/
InvalidModelSource: 0x78,
/*
* Thrown when the number of passed inputs to the model is different than the model metadata specifies.
*/
UnexpectedNumInputs: 0x79,
/*
* Thrown when an error occurs with the tokenizer or tokenization process.
*/
TokenizerError: 0xa7,
// INFO: SpeechToText errors
TokenizerError: 0x7a,

// =========================================================================
// Speech to Text errors (0xa0–0xaf)
// =========================================================================
/*
* Thrown when there's a configuration mismatch between multilingual and language settings in Speech-to-Text models.
*/
Expand All @@ -86,7 +90,9 @@ export const errorDefinitions = {
*/
StreamingInProgress: 0xa3,

// INFO: Resource Fetcher Errors
// =========================================================================
// Resource Fetcher errors (0xb0–0xbf)
// =========================================================================
/**
* Thrown when a resource fails to download. This could be due to invalid URL, or for example a network problem.
*/
Expand Down Expand Up @@ -120,10 +126,12 @@ export const errorDefinitions = {
*/
ResourceFetcherPlatformNotSupported: 0xbb,

// ExecuTorch mapped errors
// =========================================================================
// ExecuTorch mapped errors (0x00–0x3f)
// Based on: https://github.com/pytorch/executorch/blob/main/runtime/core/error.h
// =========================================================================
Comment thread
msluszniak marked this conversation as resolved.

// System errors
// System errors (0x00–0x0f)
/**
* Status indicating a successful operation.
*/
Expand All @@ -140,8 +148,12 @@ export const errorDefinitions = {
* Status indicating there are no more steps of execution to run
*/
EndOfMethod: 0x03,
/**
* Status indicating a resource has already been loaded.
*/
AlreadyLoaded: 0x04,

// Logical errors
// Logical errors (0x10–0x1f)
/**
* Operation is not supported in the current context.
*/
Expand All @@ -163,7 +175,7 @@ export const errorDefinitions = {
*/
OperatorMissing: 0x14,

// Resource errors
// Resource errors (0x20–0x2f)
/**
* Requested resource could not be found.
*/
Expand All @@ -189,7 +201,7 @@ export const errorDefinitions = {
*/
OutOfResources: 0x25,

// Delegate errors
// Delegate errors (0x30–0x3f)
/**
* Init stage: Backend receives an incompatible delegate version.
*/
Expand Down
1 change: 1 addition & 0 deletions scripts/generate-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function generateCppEnum() {
'Internal',
'InvalidState',
'EndOfMethod',
'AlreadyLoaded',
'NotSupported',
'NotImplemented',
'InvalidArgument',
Expand Down
Loading