Support thiserror 2.0.

- Adjust one bit of syntax to be compatible with `thiserror` 1.0 and
    `thiserror` 2.0, and loosen the dependency requirements to accept
    either version.
This commit is contained in:
Neal H. Walfield 2024-11-28 06:37:07 +01:00
parent 841ce9d0b5
commit 99d97c0cc3
No known key found for this signature in database
GPG Key ID: 6863C9AD5B4D22D3
3 changed files with 54 additions and 30 deletions

62
Cargo.lock generated
View File

@ -1624,7 +1624,7 @@ dependencies = [
"once_cell",
"radix_trie",
"rand",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -1647,7 +1647,7 @@ dependencies = [
"once_cell",
"openssl",
"rand",
"thiserror",
"thiserror 1.0.69",
"tinyvec",
"tokio",
"tracing",
@ -1670,7 +1670,7 @@ dependencies = [
"rand",
"resolv-conf",
"smallvec",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -2339,7 +2339,7 @@ dependencies = [
"getrandom",
"libc",
"nettle-sys",
"thiserror",
"thiserror 1.0.69",
"typenum",
]
@ -2521,7 +2521,7 @@ dependencies = [
"libc",
"sha1collisiondetection",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"walkdir",
]
@ -2676,7 +2676,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442"
dependencies = [
"memchr",
"thiserror",
"thiserror 1.0.69",
"ucd-trie",
]
@ -2980,7 +2980,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom",
"libredox",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -3125,7 +3125,7 @@ dependencies = [
"serde",
"tempfile",
"textwrap",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -3344,7 +3344,7 @@ dependencies = [
"sequoia-net",
"sequoia-openpgp",
"smallvec",
"thiserror",
"thiserror 1.0.69",
"tokio",
"url",
]
@ -3359,7 +3359,7 @@ dependencies = [
"directories",
"same-file",
"tempfile",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -3378,7 +3378,7 @@ dependencies = [
"sequoia-openpgp",
"stfu8",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
]
@ -3403,7 +3403,7 @@ dependencies = [
"sequoia-openpgp",
"socket2",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-util",
"winapi",
@ -3430,7 +3430,7 @@ dependencies = [
"sequoia-keystore-gpg-agent",
"sequoia-keystore-softkeys",
"sequoia-openpgp",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-util",
]
@ -3449,7 +3449,7 @@ dependencies = [
"log",
"sequoia-openpgp",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
]
@ -3507,7 +3507,7 @@ dependencies = [
"reqwest",
"sequoia-openpgp",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
"url",
"z-base-32",
@ -3568,7 +3568,7 @@ dependencies = [
"rsa",
"sha1collisiondetection",
"sha2",
"thiserror",
"thiserror 1.0.69",
"twofish",
"typenum",
"win-crypto-ng",
@ -3587,7 +3587,7 @@ dependencies = [
"chrono",
"sequoia-openpgp",
"serde",
"thiserror",
"thiserror 1.0.69",
"toml",
]
@ -3632,7 +3632,7 @@ dependencies = [
"termcolor",
"terminal_size",
"textwrap",
"thiserror",
"thiserror 2.0.3",
"tokio",
"toml_edit",
"typenum",
@ -3650,7 +3650,7 @@ dependencies = [
"num_cpus",
"sequoia-cert-store",
"sequoia-openpgp",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -3891,7 +3891,7 @@ dependencies = [
"tempfile",
"tempfile-fast",
"tera",
"thiserror",
"thiserror 1.0.69",
"time",
"walkdir",
]
@ -4094,7 +4094,16 @@ version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl",
"thiserror-impl 1.0.69",
]
[[package]]
name = "thiserror"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa"
dependencies = [
"thiserror-impl 2.0.3",
]
[[package]]
@ -4108,6 +4117,17 @@ dependencies = [
"syn",
]
[[package]]
name = "thiserror-impl"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.8"

View File

@ -51,7 +51,7 @@ sequoia-cert-store = "0.6.0"
sequoia-keystore = { version = ">=0.5, <0.7" }
sequoia-wot = { version = "0.13.2", default-features = false }
tempfile = "3.1"
thiserror = "1"
thiserror = { version = ">=1, <3" }
tokio = { version = "1.13.1" }
toml_edit = { version = "0.22", default-features = false, features = ["display", "parse"] }
regex = "1"

View File

@ -608,20 +608,24 @@ pub type TraversalResult<T> = std::result::Result<T, TraversalError>;
/// Errors traversing the document tree.
#[derive(thiserror::Error, Debug)]
pub enum TraversalError {
#[error("Tried to look up {1:?}{}, \
but it does not exist", Self::fmt_path("in", &.0))]
#[error("Tried to look up {1:?}{path}, \
but it does not exist",
path=Self::fmt_path("in", &.0))]
KeyNotFound(Path, String),
#[error("Tried to get the item at index {1}{}, \
but there are only {2} items", Self::fmt_path("from", &.0))]
#[error("Tried to get the item at index {1}{path}, \
but there are only {2} items",
path=Self::fmt_path("from", &.0))]
OutOfBounds(Path, usize, usize),
#[error("Tried to look up {1:?}{}, \
but the latter is a {2}, not a table", Self::fmt_path("in", &.0))]
#[error("Tried to look up {1:?}{path}, \
but the latter is a {2}, not a table",
path=Self::fmt_path("in", &.0))]
KeyLookupBadType(Path, String, &'static str),
#[error("Tried to get the item at index {1}{}, \
but the latter is a {2}, not an array", Self::fmt_path("from", &.0))]
#[error("Tried to get the item at index {1}{path}, \
but the latter is a {2}, not an array",
path=Self::fmt_path("from", &.0))]
IndexLookupBadType(Path, usize, &'static str),
}