Skip to content
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

fix: api error toast #5908

Merged
merged 7 commits into from
Sep 26, 2024
Merged

fix: api error toast #5908

merged 7 commits into from
Sep 26, 2024

Conversation

sidmorizon
Copy link
Contributor

@sidmorizon sidmorizon commented Sep 24, 2024

Summary by CodeRabbit

  • 新功能

    • 引入了 disableFallbackMessage 属性,以更好地控制错误消息的显示。
    • 更新了错误通知逻辑,允许更精确的条件判断是否显示错误提示。
  • Bug 修复

    • 修改了 ErrorToastContainertoastId 的生成逻辑,以提供更具描述性的标识符。
    • 增加了条件判断,确保在特定情况下不显示错误提示。

Copy link

codesandbox bot commented Sep 24, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@sidmorizon sidmorizon marked this pull request as ready for review September 24, 2024 07:13
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

此次更改涉及多个文件,主要集中在错误处理和通知逻辑的改进。ErrorToastContainer 现在使用更具描述性的 toastId。同时,OneKeyError 类和 IOneKeyError 接口新增了 disableFallbackMessage 属性,以控制错误消息的生成。此外,其他文件也进行了相应的调整,以支持新逻辑并优化错误通知的显示条件。

Changes

文件路径 变更摘要
packages/kit/src/provider/Container/ErrorToastContainer/ErrorToastContainer.tsx 修改 toastId 的逻辑,增强错误标识的描述性。
packages/shared/src/errors/errors/baseErrors.ts OneKeyError 类中新增 disableFallbackMessage 属性,控制回退消息的生成。
packages/shared/src/errors/types/errorTypes.ts IOneKeyError 接口中新增可选属性 disableFallbackMessage
packages/shared/src/errors/utils/errorToastUtils.ts 引入 shouldMuteToast 变量,修改错误通知的显示条件。
packages/shared/src/request/axiosInterceptor.ts OneKeyServerApiError 实例化中新增 disableFallbackMessage 属性,影响错误处理行为。

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between c43d790 and d08e1db.

📒 Files selected for processing (1)
  • packages/shared/src/request/axiosInterceptor.ts (2 hunks)
🔇 Additional comments not posted (1)
packages/shared/src/request/axiosInterceptor.ts (1)

88-88: 请解释新属性的用途

新增了 disableFallbackMessage: true。这会如何影响错误处理?为什么要禁用后备消息?请说明这一改动的目的和影响。


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or Summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sidmorizon sidmorizon enabled auto-merge (squash) September 24, 2024 07:14
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

Commits

Files that changed from the base of the PR and between 450ca22 and c43d790.

Files selected for processing (5)
  • packages/kit/src/provider/Container/ErrorToastContainer/ErrorToastContainer.tsx (1 hunks)
  • packages/shared/src/errors/errors/baseErrors.ts (3 hunks)
  • packages/shared/src/errors/types/errorTypes.ts (1 hunks)
  • packages/shared/src/errors/utils/errorToastUtils.ts (1 hunks)
  • packages/shared/src/request/axiosInterceptor.ts (2 hunks)
Additional context used
Biome
packages/shared/src/errors/utils/errorToastUtils.ts

[error] 47-48: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (3)
packages/kit/src/provider/Container/ErrorToastContainer/ErrorToastContainer.tsx (1)

26-26: 好的改动!

这个变更提高了 toastId 的描述性。现在它会优先使用错误代码,其次是标题,最后才是消息内容。这样做能更好地区分不同的提示,有助于调试和改善用户体验。

packages/shared/src/errors/errors/baseErrors.ts (1)

62-62: 新属性添加得当!

disableFallbackMessage 属性的加入增强了错误处理的灵活性。

packages/shared/src/request/axiosInterceptor.ts (1)

88-88: 解释新属性的用途

新增的disableFallbackMessage属性可能会改变错误处理方式。请解释:

  1. 这个属性的具体作用是什么?
  2. 它会如何影响用户体验?
  3. 是否需要在其他地方做相应调整?

为了全面了解这个变更的影响,请运行以下脚本:

Verification successful

确认 disableFallbackMessage 属性的添加

disableFallbackMessage 属性在 OneKeyServerApiError 类中已正确定义,并用于控制错误消息的显示。此次添加不会导致运行时错误,且符合现有的错误处理逻辑。

  • disableFallbackMessage 用于决定是否显示默认的错误消息。
  • 仅在 axiosInterceptor.ts 中添加,影响局部错误处理。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:查找其他使用OneKeyServerApiError的地方,检查是否需要类似的更改。

# 测试:搜索OneKeyServerApiError的使用。预期:找到其他使用该错误类的地方。
rg --type typescript 'new OneKeyServerApiError'

Length of output: 84


Script:

#!/bin/bash
# 描述:查找其他使用OneKeyServerApiError的地方,检查是否需要类似的更改。

# 测试:搜索OneKeyServerApiError的使用。预期:找到其他使用该错误类的地方。
rg --type ts 'new OneKeyServerApiError'

Length of output: 217


Script:

#!/bin/bash
# 描述:查找 OneKeyServerApiError 类的定义,检查 disableFallbackMessage 属性的作用。

# 测试:搜索 OneKeyServerApiError 类的定义。预期:找到类的定义及其属性说明。
rg --type ts 'class OneKeyServerApiError'

Length of output: 146


Script:

#!/bin/bash
# 描述:获取 OneKeyServerApiError 类的完整定义,以了解 disableFallbackMessage 属性的作用。

# 显示 baseErrors.ts 文件内容
cat packages/shared/src/errors/errors/baseErrors.ts

Length of output: 3945


Script:

#!/bin/bash
# 描述:查找 disableFallbackMessage 属性的定义位置,以确认其在 OneKeyServerApiError 中的作用。

# 搜索 disableFallbackMessage 在整个代码库中的定义
rg 'disableFallbackMessage' --type ts

Length of output: 467

@sidmorizon sidmorizon merged commit 4014611 into x Sep 26, 2024
5 checks passed
@sidmorizon sidmorizon deleted the fix/api-error-toast branch September 26, 2024 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants