Replace anyhow with structured error types in support crates#1755
Conversation
aa464be to
8f51404
Compare
anyhow with structured error types in support crates
|
Sounds good. This composes better with the underlying libraries |
|
Should the postgres server not also be stopped in the script? Update missed the trap |
There was a problem hiding this comment.
Note: end applications are done in the next PR
| &store_dir, | ||
| &drv_path, | ||
| format!( | ||
| r#"Derive([("out","/nix/store/{HASH}-test-src","sha256","deadbeef00000000000000000000000000000000000000000000000000000000")],[],[],"{0}","{0}",[],[("name","test-src")])"#, |
There was a problem hiding this comment.
i still think we want {HASH}, a fake hash here
There was a problem hiding this comment.
This is a preexisting error (should be separate commit). This is actually correct, the ATerm parser will complain if the hash and the store path do not agree, which is good.
There was a problem hiding this comment.
unrelated question but are we running cargo test currently in CI?
There was a problem hiding this comment.
No we aren't, it wasn't working when I first tried, only impurely. That would be a good thing to fix.
Harmonia's ATerm parser validates that CAFixed output paths match the content hash. The placeholder `aaaa...` was accepted by the older parser but is now rejected with `CAFixed output path mismatch`. Use the correct base32 hash that sha256:deadbeef... produces for name "test-src".
Introduce typed error enums so callers can distinguish error kinds
(e.g. DB infrastructure failure vs bad data) without string matching.
This lays the groundwork for the future error handling cleanups, by
allowing us to see more clearly what changes are made.
db crate:
- New `db::Error` enum: `Sql` (infrastructure) vs `Data(DataError)`
- `DataError` has `StorePath`, `StorePathName`, `IntConversion`, and
`BuildProductMissingPath { build_id, productnr }` variants
- `BuildProductRow` now carries `build` and `productnr` from the query
so error messages identify the offending row
- Removed `anyhow` dependency
nix-utils crate:
- Replaced `Error::Anyhow` catch-all with `DerivationParse` and
`StorePathName` variants
- Fixed CA fixed-output test to use correct output path
- Removed `anyhow` dependency
store-transfer crate:
- New `Error` enum: `Store`, `Grpc`, `Io`, `Protocol`, `Join`
- `ProtocolError` sub-enum: `EmptyStream`, `MissingHeader`,
`MissingGrpcField`, `InvalidPathInfo`, `TruncatedNar`
- Removed `anyhow` dependency
nix-support crate:
- `anyhow::Result` → `std::io::Result` (all errors are IO)
- Removed `anyhow` dependency
hydra-tracing crate:
- `anyhow::Result` → `Result<_, Box<dyn Error>>` (init-only)
- Removed `anyhow` dependency
binary-cache crate:
- `InvalidS3Scheme` and `InvalidCompression` error structs with
named `got` field replace `String` error variants
- `UrlParseError` variants renamed for clarity
proto crate:
- `NarInfoConvertError` now implements `std::error::Error`
Also adds `sqlx-prepare.sh` for regenerating the sqlx offline cache.
|
OK Thanks! All the |
Introduce typed error enums so callers can distinguish error kinds
(e.g. DB infrastructure failure vs bad data) without string matching.
This lays the groundwork for the future error handling cleanups, by
allowing us to see more clearly what changes are made.
db crate:
db::Errorenum:Sql(infrastructure) vsData(DataError)DataErrorhasStorePath,StorePathName,IntConversion, andBuildProductMissingPath { build_id, productnr }variantsBuildProductRownow carriesbuildandproductnrfrom the queryso error messages identify the offending row
anyhowdependencynix-utils crate:
Error::Anyhowcatch-all withDerivationParseandStorePathNamevariantsanyhowdependencystore-transfer crate:
Errorenum:Store,Grpc,Io,Protocol,JoinProtocolErrorsub-enum:EmptyStream,MissingHeader,MissingGrpcField,InvalidPathInfo,TruncatedNaranyhowdependencynix-support crate:
anyhow::Result→std::io::Result(all errors are IO)anyhowdependencyhydra-tracing crate:
anyhow::Result→Result<_, Box<dyn Error>>(init-only)anyhowdependencybinary-cache crate:
InvalidS3SchemeandInvalidCompressionerror structs withnamed
gotfield replaceStringerror variantsUrlParseErrorvariants renamed for clarityproto crate:
NarInfoConvertErrornow implementsstd::error::ErrorAlso adds
sqlx-prepare.shfor regenerating the sqlx offline cache.