Skip to content

Commit

Permalink
chore(tests): update thiserror to v2 (#1581)
Browse files Browse the repository at this point in the history
This mainly follows
https://github.com/dtolnay/thiserror/releases/tag/2.0.0 and should be
fairly straightforeward
  • Loading branch information
CommanderStorm authored Dec 11, 2024
1 parent 30e0442 commit 9331f1c
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 31 deletions.
17 changes: 14 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
8 changes: 4 additions & 4 deletions martin/src/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ pub type FileResult<T> = Result<T, FileError>;

#[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}")]
Expand Down
6 changes: 3 additions & 3 deletions martin/src/fonts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
10 changes: 5 additions & 5 deletions martin/src/pg/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ pub enum PgError {
#[error("Cannot load platform root certificates: {0:?}")]
CannotLoadRoots(Vec<rustls_native_certs::Error>),

#[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)]
Expand Down Expand Up @@ -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<UrlQuery>),

#[error("Configuration error: {0}")]
Expand Down
16 changes: 8 additions & 8 deletions martin/src/sprites/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
6 changes: 3 additions & 3 deletions martin/src/utils/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down
8 changes: 4 additions & 4 deletions mbtiles/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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}")]
Expand Down Expand Up @@ -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}")]
Expand Down

0 comments on commit 9331f1c

Please sign in to comment.