diff --git a/Cargo.lock b/Cargo.lock index 465098fa3..6fdad7e1b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2562,7 +2562,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -2701,7 +2701,7 @@ dependencies = [ "static-files", "subst", "testcontainers-modules", - "thiserror 1.0.69", + "thiserror 2.0.3", "tilejson", "tokio", "tokio-postgres-rustls", @@ -2746,7 +2746,7 @@ dependencies = [ "sqlite-compressions", "sqlite-hashes", "sqlx", - "thiserror 1.0.69", + "thiserror 2.0.3", "tilejson", "tokio", "xxhash-rust", @@ -4968,6 +4968,17 @@ dependencies = [ "syn 2.0.89", ] +[[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 2.0.87", +] + [[package]] name = "tilejson" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index 85eb687e9..96451cdc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -84,7 +84,7 @@ sqlx = { version = "0.7", features = ["sqlite", "runtime-tokio"] } static-files = "0.2" subst = { version = "0.3", features = ["yaml"] } testcontainers-modules = { version = "0.11.4", features = ["postgres"] } -thiserror = "1" +thiserror = "2" tile-grid = "0.6" tilejson = "0.4" tokio = { version = "1", features = ["macros"] } diff --git a/martin/src/file_config.rs b/martin/src/file_config.rs index 695ef9d01..e222017cc 100644 --- a/martin/src/file_config.rs +++ b/martin/src/file_config.rs @@ -21,19 +21,19 @@ pub type FileResult = Result; #[derive(thiserror::Error, Debug)] pub enum FileError { - #[error("IO error {0}: {}", .1.display())] + #[error("IO error {0}: {1}")] IoError(std::io::Error, PathBuf), - #[error("Source path is not a file: {}", .0.display())] + #[error("Source path is not a file: {0}")] InvalidFilePath(PathBuf), #[error("Error {0} while parsing URL {1}")] InvalidSourceUrl(url::ParseError, String), - #[error("Source {0} uses bad file {}", .1.display())] + #[error("Source {0} uses bad file {1}")] InvalidSourceFilePath(String, PathBuf), - #[error(r"Unable to parse metadata in file {}: {0}", .1.display())] + #[error(r"Unable to parse metadata in file {1}: {0}")] InvalidMetadata(String, PathBuf), #[error(r"Unable to parse metadata in file {1}: {0}")] diff --git a/martin/src/fonts/mod.rs b/martin/src/fonts/mod.rs index fb04a60c1..7ab657844 100644 --- a/martin/src/fonts/mod.rs +++ b/martin/src/fonts/mod.rs @@ -52,13 +52,13 @@ pub enum FontError { #[error(transparent)] FreeType(#[from] pbf_font_tools::freetype::Error), - #[error("IO error accessing {}: {0}", .1.display())] + #[error("IO error accessing {1}: {0}")] IoError(std::io::Error, PathBuf), - #[error("Invalid font file {}", .0.display())] + #[error("Invalid font file {0}")] InvalidFontFilePath(PathBuf), - #[error("No font files found in {}", .0.display())] + #[error("No font files found in {0}")] NoFontFilesFound(PathBuf), #[error("Font {0} is missing a family name")] diff --git a/martin/src/pg/errors.rs b/martin/src/pg/errors.rs index d4220274f..9df1e38bc 100644 --- a/martin/src/pg/errors.rs +++ b/martin/src/pg/errors.rs @@ -16,16 +16,16 @@ pub enum PgError { #[error("Cannot load platform root certificates: {0:?}")] CannotLoadRoots(Vec), - #[error("Cannot open certificate file {}: {0}", .1.display())] + #[error("Cannot open certificate file {1}: {0}")] CannotOpenCert(#[source] io::Error, PathBuf), - #[error("Cannot parse certificate file {}: {0}", .1.display())] + #[error("Cannot parse certificate file {1}: {0}")] CannotParseCert(#[source] io::Error, PathBuf), - #[error("Unable to parse PEM RSA key file {}", .0.display())] + #[error("Unable to parse PEM RSA key file {0}")] InvalidPrivateKey(PathBuf), - #[error("Unable to use client certificate pair {} / {}: {0}", .1.display(), .2.display())] + #[error("Unable to use client certificate pair {1} / {2}: {0}")] CannotUseClientKey(#[source] rustls::Error, PathBuf, PathBuf), #[error(transparent)] @@ -67,7 +67,7 @@ pub enum PgError { #[error(r#"Unable to get tile {2:#} from {1}: {0}"#)] GetTileError(#[source] TokioPgError, String, TileCoord), - #[error(r#"Unable to get tile {2:#} with {:?} params from {1}: {0}"#, query_to_json(.3.as_ref()))] + #[error(r#"Unable to get tile {2:#} with {json_query:?} params from {1}: {0}"#, json_query=query_to_json(.3.as_ref()))] GetTileWithQueryError(#[source] TokioPgError, String, TileCoord, Option), #[error("Configuration error: {0}")] diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 033f9631f..7817518b6 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -23,31 +23,31 @@ pub enum SpriteError { #[error("Sprite {0} not found")] SpriteNotFound(String), - #[error("IO error {0}: {}", .1.display())] + #[error("IO error {0}: {1}")] IoError(std::io::Error, PathBuf), - #[error("Sprite path is not a file: {}", .0.display())] + #[error("Sprite path is not a file: {0}")] InvalidFilePath(PathBuf), - #[error("Sprite {0} uses bad file {}", .1.display())] + #[error("Sprite {0} uses bad file {1}")] InvalidSpriteFilePath(String, PathBuf), - #[error("No sprite files found in {}", .0.display())] + #[error("No sprite files found in {0}")] NoSpriteFilesFound(PathBuf), - #[error("Sprite {} could not be loaded", .0.display())] + #[error("Sprite {0} could not be loaded")] UnableToReadSprite(PathBuf), - #[error("{0} in file {}", .1.display())] + #[error("{0} in file {1}")] SpriteProcessingError(SpreetError, PathBuf), - #[error("{0} in file {}", .1.display())] + #[error("{0} in file {1}")] SpriteParsingError(ResvgError, PathBuf), #[error("Unable to generate spritesheet")] UnableToGenerateSpritesheet, - #[error("Unable to create a sprite from file {}", .0.display())] + #[error("Unable to create a sprite from file {0}")] SpriteInstError(PathBuf), } diff --git a/martin/src/utils/error.rs b/martin/src/utils/error.rs index d59eef77c..b061daaa1 100644 --- a/martin/src/utils/error.rs +++ b/martin/src/utils/error.rs @@ -37,13 +37,13 @@ pub enum MartinError { #[error("Base path must be a valid URL path, and must begin with a '/' symbol, but is '{0}'")] BasePathError(String), - #[error("Unable to load config file {}: {0}", .1.display())] + #[error("Unable to load config file {1}: {0}")] ConfigLoadError(io::Error, PathBuf), - #[error("Unable to parse config file {}: {0}", .1.display())] + #[error("Unable to parse config file {1}: {0}")] ConfigParseError(subst::yaml::Error, PathBuf), - #[error("Unable to write config file {}: {0}", .1.display())] + #[error("Unable to write config file {1}: {0}")] ConfigWriteError(io::Error, PathBuf), #[error("No tile sources found. Set sources by giving a database connection string on command line, env variable, or a config file.")] diff --git a/mbtiles/src/errors.rs b/mbtiles/src/errors.rs index 07b30fe38..768357f81 100644 --- a/mbtiles/src/errors.rs +++ b/mbtiles/src/errors.rs @@ -7,10 +7,10 @@ use crate::{MbtType, AGG_TILES_HASH, AGG_TILES_HASH_AFTER_APPLY, AGG_TILES_HASH_ #[derive(thiserror::Error, Debug)] pub enum MbtError { - #[error("The source and destination MBTiles files are the same: {}", .0.display())] + #[error("The source and destination MBTiles files are the same: {0}")] SameSourceAndDestination(PathBuf), - #[error("The diff file and source or destination MBTiles files are the same: {}", .0.display())] + #[error("The diff file and source or destination MBTiles files are the same: {0}")] SameDiffAndSourceOrDestination(PathBuf), #[error(transparent)] @@ -22,7 +22,7 @@ pub enum MbtError { #[error(transparent)] JsonSerdeError(#[from] serde_json::Error), - #[error("MBTile filepath contains unsupported characters: {}", .0.display())] + #[error("MBTile filepath contains unsupported characters: {0}")] UnsupportedCharsInFilepath(PathBuf), #[error("Inconsistent tile formats detected: {0} vs {1}")] @@ -72,7 +72,7 @@ pub enum MbtError { #[error("The MBTiles file {0} has data of type {1}, but the desired type was set to {2}")] MismatchedTargetType(PathBuf, MbtType, MbtType), - #[error("Unless --on-duplicate (override|ignore|abort) is set, writing tiles to an existing non-empty MBTiles file is disabled. Either set --on-duplicate flag, or delete {}", .0.display())] + #[error("Unless --on-duplicate (override|ignore|abort) is set, writing tiles to an existing non-empty MBTiles file is disabled. Either set --on-duplicate flag, or delete {0}")] DestinationFileExists(PathBuf), #[error("Invalid zoom value {0}={1}, expecting an integer between 0..{MAX_ZOOM}")]