-
Notifications
You must be signed in to change notification settings - Fork 715
fix: additional error handling #4037
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
Conversation
WalkthroughThe update significantly improves error handling in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant LogsComponent
participant UseLogs
User->>LogsComponent: Requests log data
LogsComponent->>UseLogs: Calls useLogs function
UseLogs->>UseLogs: Fetches log data
alt Success
UseLogs-->>LogsComponent: Returns log data
LogsComponent-->>User: Displays log data
else Error
UseLogs-->>LogsComponent: Returns error message
LogsComponent-->>User: Displays error message
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (2)
web/src/composables/useLogs.ts (2)
Line range hint
1488-1512:
UseObject.hasOwn()instead ofObject.prototype.hasOwnProperty.It's recommended to use
Object.hasOwn()for checking properties to avoid issues with objects that might have overriddenhasOwnProperty.- if (err.response.data.hasOwnProperty("trace_id")) { + if (Object.hasOwn(err.response.data, "trace_id")) { - if (err.hasOwnProperty("trace_id")) { + if (Object.hasOwn(err, "trace_id")) {
Line range hint
1629-1653:
UseObject.hasOwn()instead ofObject.prototype.hasOwnProperty.It's recommended to use
Object.hasOwn()for checking properties to avoid issues with objects that might have overriddenhasOwnProperty.- if (err.response.data.hasOwnProperty("trace_id")) { + if (Object.hasOwn(err.response.data, "trace_id")) { - if (err.hasOwnProperty("trace_id")) { + if (Object.hasOwn(err, "trace_id")) {
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/src/composables/useLogs.ts (2 hunks)
- web/src/plugins/logs/Index.vue (7 hunks)
Additional context used
Biome
web/src/composables/useLogs.ts
[error] 1229-1229: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
[error] 1234-1234: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
Additional comments not posted (7)
web/src/plugins/logs/Index.vue (7)
100-100: Improved readability with added margin.The addition of the
q-mt-lgclass enhances the spacing around the error message, improving readability.
115-115: Improved readability with added margin.The addition of the
q-ma-lgclass enhances the spacing around the error message, improving readability.
117-117: Consistent layout with no additional margin.The addition of the
q-ma-noneclass ensures that no additional margin is applied, maintaining a consistent layout.
130-135: Enhanced user experience with error details toggle.The addition of a button for toggling error details improves user experience by allowing users to view more details if needed.
165-165: Improved readability with added margin.The addition of the
q-mt-lgclass enhances the spacing around the "no stream selected" message, improving readability.
185-185: Improved readability with added margin.The addition of the
q-mt-lgclass enhances the spacing around the "no record found" message, improving readability.
195-200: Enhanced user experience with error details toggle.The addition of a button for toggling error details improves user experience by allowing users to view more details if needed.
| .catch((err: any) => { | ||
| searchObj.loading = false; | ||
| let trace_id = ""; | ||
| searchObj.data.errorMsg = "Error while processing partition request."; | ||
| if (err.response != undefined) { | ||
| searchObj.data.errorMsg = | ||
| err.response.data.error + | ||
| " TraceID:" + | ||
| err.response.data?.trace_id; | ||
| if (err.response.data.hasOwnProperty("trace_id")) { | ||
| trace_id = err.response.data?.trace_id; | ||
| } | ||
| } else { | ||
| searchObj.data.errorMsg = err.message + " TraceID:" + err?.trace_id; | ||
| if (err.hasOwnProperty("trace_id")) { | ||
| trace_id = err?.trace_id; | ||
| } | ||
| } | ||
|
|
||
| notificationMsg.value = searchObj.data.errorMsg; | ||
|
|
||
| if (err?.request?.status >= 429) { | ||
| notificationMsg.value = err?.response?.data?.message; | ||
| searchObj.data.errorMsg = | ||
| err?.response?.data?.message; | ||
| } | ||
|
|
||
| if (trace_id) { | ||
| searchObj.data.errorMsg += | ||
| " <br><span class='text-subtitle1'>TraceID:" + | ||
| trace_id + | ||
| "</span>"; | ||
| notificationMsg.value += " TraceID:" + trace_id; | ||
| trace_id = ""; | ||
| } |
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.
Use Object.hasOwn() instead of Object.prototype.hasOwnProperty.
It's recommended to use Object.hasOwn() for checking properties to avoid issues with objects that might have overridden hasOwnProperty.
- if (err.response.data.hasOwnProperty("trace_id")) {
+ if (Object.hasOwn(err.response.data, "trace_id")) {
- if (err.hasOwnProperty("trace_id")) {
+ if (Object.hasOwn(err, "trace_id")) {Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| .catch((err: any) => { | |
| searchObj.loading = false; | |
| let trace_id = ""; | |
| searchObj.data.errorMsg = "Error while processing partition request."; | |
| if (err.response != undefined) { | |
| searchObj.data.errorMsg = | |
| err.response.data.error + | |
| " TraceID:" + | |
| err.response.data?.trace_id; | |
| if (err.response.data.hasOwnProperty("trace_id")) { | |
| trace_id = err.response.data?.trace_id; | |
| } | |
| } else { | |
| searchObj.data.errorMsg = err.message + " TraceID:" + err?.trace_id; | |
| if (err.hasOwnProperty("trace_id")) { | |
| trace_id = err?.trace_id; | |
| } | |
| } | |
| notificationMsg.value = searchObj.data.errorMsg; | |
| if (err?.request?.status >= 429) { | |
| notificationMsg.value = err?.response?.data?.message; | |
| searchObj.data.errorMsg = | |
| err?.response?.data?.message; | |
| } | |
| if (trace_id) { | |
| searchObj.data.errorMsg += | |
| " <br><span class='text-subtitle1'>TraceID:" + | |
| trace_id + | |
| "</span>"; | |
| notificationMsg.value += " TraceID:" + trace_id; | |
| trace_id = ""; | |
| } | |
| .catch((err: any) => { | |
| searchObj.loading = false; | |
| let trace_id = ""; | |
| searchObj.data.errorMsg = "Error while processing partition request."; | |
| if (err.response != undefined) { | |
| searchObj.data.errorMsg = | |
| err.response.data.error + | |
| " TraceID:" + | |
| err.response.data?.trace_id; | |
| if (Object.hasOwn(err.response.data, "trace_id")) { | |
| trace_id = err.response.data?.trace_id; | |
| } | |
| } else { | |
| searchObj.data.errorMsg = err.message + " TraceID:" + err?.trace_id; | |
| if (Object.hasOwn(err, "trace_id")) { | |
| trace_id = err?.trace_id; | |
| } | |
| } | |
| notificationMsg.value = searchObj.data.errorMsg; | |
| if (err?.request?.status >= 429) { | |
| notificationMsg.value = err?.response?.data?.message; | |
| searchObj.data.errorMsg = | |
| err?.response?.data?.message; | |
| } | |
| if (trace_id) { | |
| searchObj.data.errorMsg += | |
| " <br><span class='text-subtitle1'>TraceID:" + | |
| trace_id + | |
| "</span>"; | |
| notificationMsg.value += " TraceID:" + trace_id; | |
| trace_id = ""; | |
| } |
Tools
Biome
[error] 1229-1229: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
[error] 1234-1234: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/src/composables/useLogs.ts (2 hunks)
- web/src/plugins/logs/Index.vue (7 hunks)
Files skipped from review as they are similar to previous changes (1)
- web/src/plugins/logs/Index.vue
Additional context used
Biome
web/src/composables/useLogs.ts
[error] 1229-1229: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
[error] 1234-1234: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
Additional comments not posted (1)
web/src/composables/useLogs.ts (1)
1220-1254: LGTM! The error handling improvements are comprehensive.The changes enhance the robustness of the
useLogsfunction by ensuring that errors are properly captured and communicated.Tools
Biome
[error] 1229-1229: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
[error] 1234-1234: Do not access Object.prototype method 'hasOwnProperty' from target object.
It's recommended using Object.hasOwn() instead of using Object.hasOwnProperty().
See MDN web docs for more details.(lint/suspicious/noPrototypeBuiltins)
Summary by CodeRabbit
New Features
Bug Fixes
Style