Skip to content

Conversation

Jack251970
Copy link
Member

Handle exception in task. Issue from #3617.

Resolve exception message like:

Flow Launcher version: 1.20.0
OS Version: 19045.5854
IntPtr Length: 8
x64: True

Python Path: C:\Mamba\pythonw.exe
Node Path: C:\Program Files\nodejs\node.exe

Date: 06/03/2025 20:00:18
Exception:
System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Error code returned from https://github.com/Flow-Launcher/Flow.Launcher.Plugin.Explorer/releases/download/v3.2.4/Flow.Launcher.Plugin.Explorer.zip)
---> System.Net.Http.HttpRequestException: Error code returned from https://github.com/Flow-Launcher/Flow.Launcher.Plugin.Explorer/releases/download/v3.2.4/Flow.Launcher.Plugin.Explorer.zip
at Flow.Launcher.Infrastructure.Http.Http.DownloadAsync(String url, String filePath, Action`1 reportProgress, CancellationToken token) in C:\projects\flow-launcher\Flow.Launcher.Infrastructure\Http\Http.cs:line 133
at Flow.Launcher.Plugin.PluginsManager.PluginsManager.DownloadFileAsync(String prgBoxTitle, String downloadUrl, String filePath, CancellationTokenSource cts, Boolean deleteFile, Boolean showProgress) in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.PluginsManager\PluginsManager.cs:line 226
at Flow.Launcher.Plugin.PluginsManager.PluginsManager.<>c__DisplayClass19_2.<b__7>d.MoveNext() in C:\projects\flow-launcher\Plugins\Flow.Launcher.Plugin.PluginsManager\PluginsManager.cs:line 325
--- End of inner exception stack trace ---

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves exception handling during plugin downloads by replacing a ContinueWith-based continuation with an inline try-catch block, providing more granular error reporting.

  • Replaces delegate syntax with a lambda expression and wraps the async download in a try-catch block
  • Differentiates HttpRequestException from general exceptions with tailored error messages and logging
Comments suppressed due to low confidence (1)

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs:376

  • Verify that using distinct translation keys for installation errors here versus download errors in the previous block is intentional, to ensure consistent user-facing error messaging.
catch (Exception e)

Copy link

github-actions bot commented Jun 4, 2025

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 22
⚠️ non-alpha-in-dictionary 13

See ❌ Event descriptions for more information.

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

Copy link

gitstream-cm bot commented Jun 4, 2025

🥷 Code experts: onesounds

Jack251970, onesounds have most 👩‍💻 activity in the files.
Jack251970 has most 🧠 knowledge in the files.

See details

Flow.Launcher/PublicAPIInstance.cs

Activity based on git-commit:

Jack251970 onesounds
JUN
MAY 124 additions & 131 deletions 190 additions & 74 deletions
APR 165 additions & 61 deletions
MAR 21 additions & 19 deletions
FEB 28 additions & 11 deletions
JAN 45 additions & 47 deletions

Knowledge based on git-blame:
Jack251970: 49%

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

Activity based on git-commit:

Jack251970 onesounds
JUN
MAY
APR 36 additions & 40 deletions
MAR 10 additions & 7 deletions
FEB 41 additions & 30 deletions
JAN 291 additions & 247 deletions

Knowledge based on git-blame:
Jack251970: 21%

To learn more about /:\ gitStream - Visit our Docs

Copy link

gitstream-cm bot commented Jun 4, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link
Contributor

coderabbitai bot commented Jun 4, 2025

📝 Walkthrough

Walkthrough

This update refactors error handling and task structure in the plugin update workflow. It introduces explicit try-catch blocks for exceptions during asynchronous plugin updates, improves error messaging, and makes minor formatting adjustments. No changes are made to public API signatures or exported entities.

Changes

Files Change Summary
Flow.Launcher/PublicAPIInstance.cs Corrected whitespace in a lambda expression for HttpDownloadAsync; no logic or behavior changes.
Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs Refactored async plugin update task: switched to async lambda, added explicit try-catch, improved error handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PluginsManager
    participant PluginDownloader
    participant Logger
    participant UI

    User->>PluginsManager: RequestUpdateAsync()
    PluginsManager->>PluginsManager: Task.Run(async lambda)
    PluginsManager->>PluginDownloader: Download plugin (if not local)
    PluginDownloader-->>PluginsManager: Download result
    PluginsManager->>PluginsManager: Check cancellation
    alt Not cancelled
        PluginsManager->>PluginsManager: Update plugin
        PluginsManager->>UI: Show success message
        alt AutoRestartAfterChanging
            PluginsManager->>UI: Show restart message
        end
    else Cancelled
        PluginsManager->>UI: Show cancellation message
    end
    PluginsManager->>Logger: Log exceptions (on error)
    PluginsManager->>UI: Show error message (on error)
Loading

Possibly related PRs

  • Flow-Launcher/Flow.Launcher#3604: Improves error handling in plugin update tasks by adding try-catch blocks around HTTP download calls, similar to this PR's focus on exception handling.
  • Flow-Launcher/Flow.Launcher#3170: Adds progress reporting and new APIs to HttpDownloadAsync in PublicAPIInstance.cs, which is also touched (formatting only) in this PR.

Suggested labels

bug

Suggested reviewers

  • onesounds
  • jjw24

Poem

A rabbit hops through lines anew,
Catching errors as they grew.
With careful paws and gentle might,
It tames exceptions left and right.
Now plugins update, calm and clear—
No more surprises, nothing to fear!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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 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.

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: 0

🧹 Nitpick comments (1)
Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs (1)

199-199: Consider using full word for clarity.

The parameter name prgBoxTitle uses the abbreviation "prg" which triggers spelling warnings. Consider renaming to progressBoxTitle for better clarity and to avoid pipeline warnings.

-private async Task DownloadFileAsync(string prgBoxTitle, string downloadUrl, string filePath, CancellationTokenSource cts, bool deleteFile = true, bool showProgress = true)
+private async Task DownloadFileAsync(string progressBoxTitle, string downloadUrl, string filePath, CancellationTokenSource cts, bool deleteFile = true, bool showProgress = true)
🧰 Tools
🪛 GitHub Check: Check Spelling

[warning] 199-199:
prg is not a recognized word. (unrecognized-spelling)

🪛 GitHub Actions: Check Spelling

[warning] 199-199: prg is not a recognized word. (unrecognized-spelling)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 367bf2c and f60585f.

📒 Files selected for processing (2)
  • Flow.Launcher/PublicAPIInstance.cs (1 hunks)
  • Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs (1)
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs (6)
  • GetTranslation (141-141)
  • ShowMsg (119-119)
  • ShowMsg (128-128)
  • RestartApp (34-34)
  • ShowMsgError (85-85)
  • LogException (281-281)
🪛 GitHub Actions: Check Spelling
Flow.Launcher/PublicAPIInstance.cs

[warning] 52-52: Ioc is not a recognized word. (unrecognized-spelling)


[warning] 150-174: VSTHRD is not a recognized word. (unrecognized-spelling)

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs

[warning] 199-199: prg is not a recognized word. (unrecognized-spelling)


[warning] 207-207: prg is not a recognized word. (unrecognized-spelling)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (3)
Flow.Launcher/PublicAPIInstance.cs (1)

253-254: LGTM! Good formatting fix.

The whitespace addition after the lambda arrow follows standard C# formatting conventions.

Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs (2)

319-387: Excellent fix for handling unobserved task exceptions!

The refactoring properly addresses the issue by:

  • Wrapping the entire async operation in try-catch blocks
  • Explicitly handling HttpRequestException for download failures with user-friendly error messages
  • Providing general exception handling as a fallback
  • Ensuring proper logging of exceptions for debugging

Moving the CancellationTokenSource instantiation inside the try block is also a good practice.


453-458: Good consistency improvement for error messaging.

Using ShowMsgError instead of ShowMsg in the exception handler ensures proper error indication to users with the appropriate error icon.

@Jack251970 Jack251970 added the bug Something isn't working label Jun 4, 2025
@jjw24 jjw24 added this to the 1.20.1 milestone Jun 4, 2025
@jjw24 jjw24 linked an issue Jun 4, 2025 that may be closed by this pull request
2 tasks
@jjw24 jjw24 merged commit 524fb6a into dev Jun 4, 2025
16 of 18 checks passed
@jjw24 jjw24 deleted the handle_download_exception branch June 4, 2025 11:56
@jjw24 jjw24 changed the title Handle download exception Handle plugin download exception from wrong url Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: FL Preinstalled Plugin Version Issue

2 participants