You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 65915c0
Browse filesBrowse the repository at this point in the historyBrowse files
ci: verify generated error codes stay in sync with errors.config.ts (#1214)
## Description
`scripts/generate-errors.ts` (`yarn codegen:errors`) is the single
source of truth for error codes, emitting `src/errors/ErrorCodes.ts` and
`common/rnexecutorch/ErrorCodes.h`. Nothing in CI verified the committed
generated files match `errors.config.ts`, so a contributor editing the
config (or a generated file) without rerunning codegen could commit
sources that silently disagree across the JSI boundary.
This adds a `lint`-job step that reruns codegen and diffs both generated
files against what's committed, failing CI on drift. No native toolchain
needed.
While wiring this up, the committed `ErrorCodes.h` is now stored
verbatim as the generator emits it. The `clang-format` pre-commit hook
previously rewrapped its comments, which would have made the raw diff
fail in CI, so the generated header is excluded from that hook.
### Introduces a breaking change?
- [ ] Yes
- [x] No
### Type of change
- [x] Other (chores, tests, code style improvements etc.)
### Tested on
- [ ] iOS
- [ ] Android
### Testing instructions
1. Edit `scripts/errors.config.ts` (e.g. rename a code) without running
codegen.
2. The new "Verify error codes are up to date" CI step fails with a
stale-codes error.
3. Run `yarn codegen:errors`, commit the result — the step passes.
### Related issues
Closes#1209
### Checklist
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have updated the documentation accordingly
- [x] My changes generate no new warnings
Copy file name to clipboardExpand all lines: packages/react-native-executorch/common/rnexecutorch/ErrorCodes.h
+20-44Lines changed: 20 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -9,108 +9,87 @@ namespace rnexecutorch {
9
9
10
10
enumclassRnExecutorchErrorCode : int32_t {
11
11
/**
12
-
* An umbrella-error that is thrown usually when something unexpected happens,
13
-
* for example a 3rd-party library error.
12
+
* An umbrella-error that is thrown usually when something unexpected happens, for example a 3rd-party library error.
14
13
*/
15
14
UnknownError = 101,
16
15
/**
17
-
* Thrown when a user tries to run a model that is not yet downloaded or
18
-
* loaded into memory.
16
+
* Thrown when a user tries to run a model that is not yet downloaded or loaded into memory.
19
17
*/
20
18
ModuleNotLoaded = 102,
21
19
/**
22
-
* An error ocurred when saving a file. This could be, for instance a result
23
-
* image from an image model.
20
+
* An error ocurred when saving a file. This could be, for instance a result image from an image model.
24
21
*/
25
22
FileWriteFailed = 103,
26
23
/**
27
-
* Thrown when a user tries to run a model that is currently processing. It is
28
-
* only allowed to run a single model prediction at a time.
24
+
* Thrown when a user tries to run a model that is currently processing. It is only allowed to run a single model prediction at a time.
29
25
*/
30
26
ModelGenerating = 104,
31
27
/**
32
-
* Thrown when a language is passed to a multi-language model that is not
33
-
* supported. For example OCR or Speech To Text.
28
+
* Thrown when a language is passed to a multi-language model that is not supported. For example OCR or Speech To Text.
34
29
*/
35
30
LanguageNotSupported = 105,
36
31
/**
37
-
* Thrown when config parameters passed to a model are invalid. For example,
38
-
* when LLM's topp is outside of range [0, 1].
32
+
* Thrown when config parameters passed to a model are invalid. For example, when LLM's topp is outside of range [0, 1].
39
33
*/
40
34
InvalidConfig = 112,
41
35
/**
42
36
* Thrown when React Native ExecuTorch threadpool problem occurs.
43
37
*/
44
38
ThreadPoolError = 113,
45
39
/**
46
-
* Thrown when a file read operation failed. This could be invalid image url
47
-
* passed to image models, or unsupported format.
40
+
* Thrown when a file read operation failed. This could be invalid image url passed to image models, or unsupported format.
48
41
*/
49
42
FileReadFailed = 114,
50
43
/**
51
-
* Thrown when the size of model output is unexpected. If you're using your
52
-
* custom model with any of the pre-defined modules, please verify docs or
53
-
* source code for the expected model I/O contract.
44
+
* Thrown when the size of model output is unexpected. If you're using your custom model with any of the pre-defined modules, please verify docs or source code for the expected model I/O contract.
54
45
*/
55
46
InvalidModelOutput = 115,
56
47
/**
57
-
* Thrown when the dimensions of input tensors don't match the model's
58
-
* expected dimensions.
48
+
* Thrown when the dimensions of input tensors don't match the model's expected dimensions.
59
49
*/
60
50
WrongDimensions = 116,
61
51
/**
62
-
* Thrown when the input passed to our APIs is invalid, for example when
63
-
* passing an empty message array to LLM's generate().
52
+
* Thrown when the input passed to our APIs is invalid, for example when passing an empty message array to LLM's generate().
64
53
*/
65
54
InvalidUserInput = 117,
66
55
/**
67
-
* Thrown when the number of downloaded files is unexpected, due to download
68
-
* interruptions.
56
+
* Thrown when the number of downloaded files is unexpected, due to download interruptions.
69
57
*/
70
58
DownloadInterrupted = 118,
71
59
/**
72
-
* Thrown when a feature or platform is not supported in the current
73
-
* environment.
60
+
* Thrown when a feature or platform is not supported in the current environment.
74
61
*/
75
62
PlatformNotSupported = 119,
76
63
/**
77
64
* Thrown when the type of model source passed by the user is invalid.
78
65
*/
79
66
InvalidModelSource = 120,
80
67
/**
81
-
* Thrown when the number of passed inputs to the model is different than the
82
-
* model metadata specifies. If you're using your custom model with any of the
83
-
* pre-defined modules, please verify docs or source code for the expected
84
-
* model I/O contract.
68
+
* Thrown when the number of passed inputs to the model is different than the model metadata specifies. If you're using your custom model with any of the pre-defined modules, please verify docs or source code for the expected model I/O contract.
85
69
*/
86
70
UnexpectedNumInputs = 121,
87
71
/**
88
72
* Thrown when an error occurs with the tokenizer or tokenization process.
89
73
*/
90
74
TokenizerError = 122,
91
75
/**
92
-
* Thrown when there's a configuration mismatch between multilingual and
93
-
* language settings in Speech-to-Text models.
76
+
* Thrown when there's a configuration mismatch between multilingual and language settings in Speech-to-Text models.
94
77
*/
95
78
MultilingualConfiguration = 160,
96
79
/**
97
-
* Thrown when streaming transcription is attempted but audio data chunk is
98
-
* missing.
80
+
* Thrown when streaming transcription is attempted but audio data chunk is missing.
99
81
*/
100
82
MissingDataChunk = 161,
101
83
/**
102
-
* Thrown when trying to stop or insert data into a stream that hasn't been
103
-
* started.
84
+
* Thrown when trying to stop or insert data into a stream that hasn't been started.
104
85
*/
105
86
StreamingNotStarted = 162,
106
87
/**
107
-
* Thrown when trying to start a new streaming session while another is
108
-
* already in progress.
88
+
* Thrown when trying to start a new streaming session while another is already in progress.
109
89
*/
110
90
StreamingInProgress = 163,
111
91
/**
112
-
* Thrown when a resource fails to download. This could be due to invalid URL,
113
-
* or for example a network problem.
92
+
* Thrown when a resource fails to download. This could be due to invalid URL, or for example a network problem.
114
93
*/
115
94
ResourceFetcherDownloadFailed = 180,
116
95
/**
@@ -126,8 +105,7 @@ enum class RnExecutorchErrorCode : int32_t {
126
105
*/
127
106
ResourceFetcherAlreadyOngoing = 183,
128
107
/**
129
-
* Thrown when trying to pause, resume, or cancel a download that is not
130
-
* active.
108
+
* Thrown when trying to pause, resume, or cancel a download that is not active.
131
109
*/
132
110
ResourceFetcherNotActive = 184,
133
111
/**
@@ -139,9 +117,7 @@ enum class RnExecutorchErrorCode : int32_t {
139
117
*/
140
118
ResourceFetcherAdapterNotInitialized = 186,
141
119
/**
142
-
* Thrown when the platform does not support the resource fetching feature,
143
-
* which is required for downloading models and other resources in React
144
-
* Native ExecuTorch.
120
+
* Thrown when the platform does not support the resource fetching feature, which is required for downloading models and other resources in React Native ExecuTorch.
0 commit comments