Skip to content

Commit 50cde2c

Browse files
committed
object_store/lib: Migrate from snafu to thiserror
1 parent 19a78fa commit 50cde2c

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

object_store/src/lib.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ use async_trait::async_trait;
562562
use bytes::Bytes;
563563
use chrono::{DateTime, Utc};
564564
use futures::{stream::BoxStream, StreamExt, TryStreamExt};
565-
use snafu::Snafu;
566565
use std::fmt::{Debug, Formatter};
567566
#[cfg(not(target_arch = "wasm32"))]
568567
use std::io::{Read, Seek, SeekFrom};
@@ -1223,78 +1222,81 @@ pub struct PutResult {
12231222
pub type Result<T, E = Error> = std::result::Result<T, E>;
12241223

12251224
/// A specialized `Error` for object store-related errors
1226-
#[derive(Debug, Snafu)]
1225+
#[derive(Debug, thiserror::Error)]
12271226
#[allow(missing_docs)]
12281227
#[non_exhaustive]
12291228
pub enum Error {
1230-
#[snafu(display("Generic {} error: {}", store, source))]
1229+
#[error("Generic {} error: {}", store, source)]
12311230
Generic {
12321231
store: &'static str,
12331232
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12341233
},
12351234

1236-
#[snafu(display("Object at location {} not found: {}", path, source))]
1235+
#[error("Object at location {} not found: {}", path, source)]
12371236
NotFound {
12381237
path: String,
12391238
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12401239
},
12411240

1242-
#[snafu(
1243-
display("Encountered object with invalid path: {}", source),
1244-
context(false)
1245-
)]
1246-
InvalidPath { source: path::Error },
1241+
#[error("Encountered object with invalid path: {}", source)]
1242+
InvalidPath {
1243+
#[from]
1244+
source: path::Error,
1245+
},
12471246

1248-
#[snafu(display("Error joining spawned task: {}", source), context(false))]
1249-
JoinError { source: tokio::task::JoinError },
1247+
#[error("Error joining spawned task: {}", source)]
1248+
JoinError {
1249+
#[from]
1250+
source: tokio::task::JoinError,
1251+
},
12501252

1251-
#[snafu(display("Operation not supported: {}", source))]
1253+
#[error("Operation not supported: {}", source)]
12521254
NotSupported {
12531255
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12541256
},
12551257

1256-
#[snafu(display("Object at location {} already exists: {}", path, source))]
1258+
#[error("Object at location {} already exists: {}", path, source)]
12571259
AlreadyExists {
12581260
path: String,
12591261
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12601262
},
12611263

1262-
#[snafu(display("Request precondition failure for path {}: {}", path, source))]
1264+
#[error("Request precondition failure for path {}: {}", path, source)]
12631265
Precondition {
12641266
path: String,
12651267
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12661268
},
12671269

1268-
#[snafu(display("Object at location {} not modified: {}", path, source))]
1270+
#[error("Object at location {} not modified: {}", path, source)]
12691271
NotModified {
12701272
path: String,
12711273
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12721274
},
12731275

1274-
#[snafu(display("Operation not yet implemented."))]
1276+
#[error("Operation not yet implemented.")]
12751277
NotImplemented,
12761278

1277-
#[snafu(display(
1279+
#[error(
12781280
"The operation lacked the necessary privileges to complete for path {}: {}",
12791281
path,
12801282
source
1281-
))]
1283+
)]
12821284
PermissionDenied {
12831285
path: String,
12841286
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12851287
},
12861288

1287-
#[snafu(display(
1289+
#[error(
12881290
"The operation lacked valid authentication credentials for path {}: {}",
12891291
path,
12901292
source
1291-
))]
1293+
)]
12921294
Unauthenticated {
12931295
path: String,
12941296
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12951297
},
12961298

1297-
#[snafu(display("Configuration key: '{}' is not valid for store '{}'.", key, store))]
1299+
#[error("Configuration key: '{}' is not valid for store '{}'.", key, store)]
12981300
UnknownConfigurationKey { store: &'static str, key: String },
12991301
}
13001302

0 commit comments

Comments
 (0)