-
Notifications
You must be signed in to change notification settings - Fork 161
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
Error refactoring and thiserror
2.0
#1588
base: next
Are you sure you want to change the base?
Conversation
I would modify |
Sounds good.
I would do only the minimal necessary changes for now, because updating our miette fork from 7.1.0 to the latest miette at 7.4.0 comes with a bunch of conflicts. And if we can get miette to support no_std and use thiserror 2.0 then that will be obsolete. |
You should be able to write to it now.
Yes, let's do the minimal changes for now. |
34fc6a6
to
6c7a841
Compare
Use
thiserror
2.0 and refactor errors to be mostly in line with how our other errors are structured, e.g. see 0xPolygonMiden/miden-base#972.So this changes errors to use lowercase messages without trailing punctuation and prefer source style over wrapping source errors.
Other notable changes include:
SourceManagerError::Custom
variant which, I think, makes sense to include asSourceManager
is a trait implementable by other crates which cannot add variants toSourceManagerError
. Let me know if this is not what we want.EventError(String)
was changed toEventError(Box<dyn Error>)
.#[source]
for errors that turn into Report, becauseReport
does not implementcore::error::Error
and so source errors would be effectively swallowed that way.There is a problem with building the
assembly
crate for wasm/no-std with this change. If I understand everything correctly, then this is because of the following.miden_miette
usesmiden_thiserror
which exposesStdError
. If we use neither a nightly compiler nor thestd
flag thenStdError
is not a reexport of thecore::error::Error
type but rather a copy of theError
trait, which means it is a separate type.miden_miette
however with itsDiagnostic
trait expectsStdError
and that trait is no longer implemented by some errors, likeSyntaxError
. This previously worked because we usedmiden_thiserror
to derive errors and so in that configuration, the derived error wasStdError
and that always matched whatmiden_miette
was expecting.It seems to me the proper fix would be to modify
miden_miette
to usethiserror
2.0. I've tested this change locally and both std and no-std works. This would makemiden_thiserror
obsolete, and we could consider yanking that crate.My question is whether we want to go ahead with this change in
miden_miette
or not. Pinging @bitwalker, as I think you've made the no-std changes tomiden-thiserror
andmiden-miette
.Or should we go one step further and ask if the
miette
author would be open to have the no_std changes upstreamed?closes #1261