-
Notifications
You must be signed in to change notification settings - Fork 299
Introduce Centralized Typed Error Model Across SDKs #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #ifndef RAC_ERROR_MODEL_H | ||
| #define RAC_ERROR_MODEL_H | ||
|
|
||
| #include "rac/core/rac_error.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /** | ||
| * @brief Structured error model for RunAnywhere SDKs | ||
| * | ||
| * This wraps existing rac_result_t codes into a typed, | ||
| * structured error representation for cross-SDK consistency. | ||
| */ | ||
| typedef struct { | ||
| rac_result_t code; /**< Numeric error code */ | ||
| const char* message; /**< Human-readable error message */ | ||
| const char* category; /**< Error category (e.g., Model, Network, Validation) */ | ||
| } rac_error_model_t; | ||
|
|
||
| /** | ||
| * @brief Create structured error model from error code | ||
| */ | ||
| rac_error_model_t rac_make_error_model(rac_result_t code); | ||
|
|
||
| /** | ||
| * @brief Get error category string from error code | ||
| */ | ||
| const char* rac_error_category(rac_result_t code); | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif // RAC_ERROR_MODEL_H | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,44 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rac/core/rac_error_model.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "rac/core/rac_error.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include <string.h> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused include -
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: sdk/runanywhere-commons/src/core/rac_error_model.cpp
Line: 4
Comment:
Unused include - `<string.h>` is not used anywhere in this file
```suggestion
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Internal Helper: Determine Category from Error Code Range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const char* rac_error_category(rac_result_t code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -109 && code <= -100) return "Initialization"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -129 && code <= -110) return "Model"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -149 && code <= -130) return "Generation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -179 && code <= -150) return "Network"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -219 && code <= -180) return "Storage"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -229 && code <= -220) return "Hardware"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -249 && code <= -230) return "ComponentState"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -279 && code <= -250) return "Validation"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -299 && code <= -280) return "Audio"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -319 && code <= -300) return "LanguageVoice"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -329 && code <= -320) return "Authentication"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -349 && code <= -330) return "Security"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -369 && code <= -350) return "Extraction"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -379 && code <= -370) return "Calibration"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -499 && code <= -400) return "ModuleService"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -599 && code <= -500) return "PlatformAdapter"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -699 && code <= -600) return "Backend"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -799 && code <= -700) return "Event"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code >= -899 && code <= -800) return "Other"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+9
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing category mapping for cancellation error range (-380 to -389) The cancellation range is defined in
Suggested change
Prompt To Fix With AIThis is a comment left during a code review.
Path: sdk/runanywhere-commons/src/core/rac_error_model.cpp
Line: 9-28
Comment:
Missing category mapping for cancellation error range (-380 to -389)
The cancellation range is defined in `rac_error.h` but not handled here, causing `RAC_ERROR_CANCELLED` (-380) to return "Unknown" instead of "Cancellation".
```suggestion
const char* rac_error_category(rac_result_t code) {
if (code >= -109 && code <= -100) return "Initialization";
if (code >= -129 && code <= -110) return "Model";
if (code >= -149 && code <= -130) return "Generation";
if (code >= -179 && code <= -150) return "Network";
if (code >= -219 && code <= -180) return "Storage";
if (code >= -229 && code <= -220) return "Hardware";
if (code >= -249 && code <= -230) return "ComponentState";
if (code >= -279 && code <= -250) return "Validation";
if (code >= -299 && code <= -280) return "Audio";
if (code >= -319 && code <= -300) return "LanguageVoice";
if (code >= -329 && code <= -320) return "Authentication";
if (code >= -349 && code <= -330) return "Security";
if (code >= -369 && code <= -350) return "Extraction";
if (code >= -379 && code <= -370) return "Calibration";
if (code >= -389 && code <= -380) return "Cancellation";
if (code >= -499 && code <= -400) return "ModuleService";
if (code >= -599 && code <= -500) return "PlatformAdapter";
if (code >= -699 && code <= -600) return "Backend";
if (code >= -799 && code <= -700) return "Event";
if (code >= -899 && code <= -800) return "Other";
```
How can I resolve this? If you propose a fix, please make it concise. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (code == RAC_SUCCESS) return "Success"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return "Unknown"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Public API: Create Structured Error Model | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rac_error_model_t rac_make_error_model(rac_result_t code) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rac_error_model_t model; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model.code = code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model.message = rac_error_message(code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| model.category = rac_error_category(code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return model; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline at end of file
Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!