Skip to content

Conversation

@lucasfernog
Copy link
Member

I know this is controversial but I've had a weird "directory not empty" error when building iOS apps that seems to be related to the gen/apple/build folder, but I had to guess it and it's impossible to trace it.. so I decided to drop anyhow to force us to be more explicit about what happened when something goes wrong.

This PR:

  • drops anyhow
  • uses thiserror instead, with variants including more context about what actually failed
  • keeps the anyhow::Context thingy because that's so cool
  • doesn't try to do too much, keeping some tech debt specially in the bundler error type
  • it's so damn verbose :( and it took away 4 hours of my life

@lucasfernog lucasfernog requested a review from a team as a code owner August 31, 2025 02:43
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Aug 31, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 31, 2025

Package Changes Through 32442c2

There are 9 changes which include @tauri-apps/api with minor, tauri-cli with minor, tauri-utils with minor, tauri-runtime-wry with minor, tauri-runtime with minor, tauri with minor, tauri-bundler with minor, @tauri-apps/cli with minor, tauri-macros with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.8.0 2.9.0
tauri-utils 2.7.0 2.8.0
tauri-bundler 2.6.1 2.7.0
tauri-runtime 2.8.0 2.9.0
tauri-runtime-wry 2.8.1 2.9.0
tauri-codegen 2.4.0 2.4.1
tauri-macros 2.4.0 2.4.1
tauri-plugin 2.4.0 2.4.1
tauri-build 2.4.1 2.4.2
tauri 2.8.5 2.9.0
@tauri-apps/cli 2.8.4 2.9.0
tauri-cli 2.8.4 2.9.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@lucasfernog
Copy link
Member Author

pretty sure CI will fail here, I only did the macOS part so far

@lucasfernog
Copy link
Member Author

will be paired with tauri-apps/cargo-mobile2#485 on release

@Legend-Master
Copy link
Contributor

Didn't look at the whole thing yet, but I think if we want to actually enforce this, we need a helper function like context for the fs errors or it will just be too annoying that nobody actually wants to use it 😂

@lucasfernog
Copy link
Member Author

Didn't look at the whole thing yet, but I think if we want to actually enforce this, we need a helper function like context for the fs errors or it will just be too annoying that nobody actually wants to use it 😂

that's a good idea, i wanted to do a second pass on it.. i'm running some prompts now

Comment on lines 16 to 18
/// Bundler error.
#[error("{0:#}")]
BundlerError(#[from] anyhow::Error),
Copy link
Member

Choose a reason for hiding this comment

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

Can we revert this and add a todo and change the docs saying that this variant is unused now? There are projects using tauri-bundler and this is a breaking api change.

Copy link
Member

Choose a reason for hiding this comment

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

otherwise this looks good i think (at least for a start). couldn't test it that much though cause i can't think of many ways to trigger errors on windows. i guess time will tell how good of a start this is :D

@lucasfernog lucasfernog requested a review from FabianLars October 1, 2025 11:13
FabianLars
FabianLars previously approved these changes Oct 1, 2025
use std::{borrow::Cow, fmt::Display, path::PathBuf};

#[derive(Debug, thiserror::Error)]
pub enum Error {
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, I'm a bit concerned about so many errors, this could be quite hard to follow through and find the right error to propagate, and in most cases, CLI errors are just some plain texts explaining what's going on

Copy link
Member Author

Choose a reason for hiding this comment

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

most of them are using #[from] except the ones that have context

alternatively we can remove most of the variants here and enforce usage of the context trait (which was the idea here tbh, adding context to every single error out there, but it's impossible to do so using the anyhow crate because it doesn't enforce it, so i had to break compilation for the entire codebase to spot the places that needed it)

Copy link
Contributor

Choose a reason for hiding this comment

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

alternatively we can remove most of the variants here and enforce usage of the context trait (which was the idea here tbh, adding context to every single error out there, but it's impossible to do so using the anyhow crate because it doesn't enforce it, so i had to break compilation for the entire codebase to spot the places that needed it)

That sounds much better to me, enforcing an error context is much more useful than having an error saying it is a JsonError (not sure how annoying would that be when writing staffs though 😂, we could try that out anyways)

Copy link
Member Author

Choose a reason for hiding this comment

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

pushed some further cleanup; i'd say we should make additional changes in a separate PR 😂

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks much better, we could maybe add a few variant and helps like fs_context for some commonly used ones in the future

Legend-Master
Legend-Master previously approved these changes Oct 2, 2025
Copy link
Contributor

@Legend-Master Legend-Master left a comment

Choose a reason for hiding this comment

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

Not entirely sure how I would test this (e.g. making something fail), code and design look good though

@lucasfernog
Copy link
Member Author

easiest thing you can do is get something to fail 😂 break cargo.toml / tauri.conf.json for instance

@lucasfernog lucasfernog merged commit b06b3bd into dev Oct 2, 2025
6 of 7 checks passed
@lucasfernog lucasfernog deleted the refactor/errors branch October 2, 2025 09:58
@github-project-automation github-project-automation bot moved this from 📬Proposal to 🔎 In audit in Roadmap Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🔎 In audit

Development

Successfully merging this pull request may close these issues.

4 participants