Skip to content

Commit 99e7473

Browse files
committed
object_store/lib: Migrate from snafu to thiserror
1 parent 3b9b5bc commit 99e7473

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

object_store/src/lib.rs

Lines changed: 17 additions & 19 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,11 +1222,11 @@ 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
#[non_exhaustive]
12281227
pub enum Error {
12291228
/// A fallback error type when no variant matches
1230-
#[snafu(display("Generic {} error: {}", store, source))]
1229+
#[error("Generic {} error: {}", store, source)]
12311230
Generic {
12321231
/// The store this error originated from
12331232
store: &'static str,
@@ -1236,7 +1235,7 @@ pub enum Error {
12361235
},
12371236

12381237
/// Error when the object is not found at given location
1239-
#[snafu(display("Object at location {} not found: {}", path, source))]
1238+
#[error("Object at location {} not found: {}", path, source)]
12401239
NotFound {
12411240
/// The path to file
12421241
path: String,
@@ -1245,31 +1244,30 @@ pub enum Error {
12451244
},
12461245

12471246
/// Error for invalid path
1248-
#[snafu(
1249-
display("Encountered object with invalid path: {}", source),
1250-
context(false)
1251-
)]
1247+
#[error("Encountered object with invalid path: {}", source)]
12521248
InvalidPath {
12531249
/// The wrapped error
1250+
#[from]
12541251
source: path::Error,
12551252
},
12561253

12571254
/// Error when `tokio::spawn` failed
1258-
#[snafu(display("Error joining spawned task: {}", source), context(false))]
1255+
#[error("Error joining spawned task: {}", source)]
12591256
JoinError {
12601257
/// The wrapped error
1258+
#[from]
12611259
source: tokio::task::JoinError,
12621260
},
12631261

12641262
/// Error when the attempted operation is not supported
1265-
#[snafu(display("Operation not supported: {}", source))]
1263+
#[error("Operation not supported: {}", source)]
12661264
NotSupported {
12671265
/// The wrapped error
12681266
source: Box<dyn std::error::Error + Send + Sync + 'static>,
12691267
},
12701268

12711269
/// Error when the object already exists
1272-
#[snafu(display("Object at location {} already exists: {}", path, source))]
1270+
#[error("Object at location {} already exists: {}", path, source)]
12731271
AlreadyExists {
12741272
/// The path to the
12751273
path: String,
@@ -1278,7 +1276,7 @@ pub enum Error {
12781276
},
12791277

12801278
/// Error when the required conditions failed for the operation
1281-
#[snafu(display("Request precondition failure for path {}: {}", path, source))]
1279+
#[error("Request precondition failure for path {}: {}", path, source)]
12821280
Precondition {
12831281
/// The path to the file
12841282
path: String,
@@ -1287,7 +1285,7 @@ pub enum Error {
12871285
},
12881286

12891287
/// Error when the object at the location isn't modified
1290-
#[snafu(display("Object at location {} not modified: {}", path, source))]
1288+
#[error("Object at location {} not modified: {}", path, source)]
12911289
NotModified {
12921290
/// The path to the file
12931291
path: String,
@@ -1296,16 +1294,16 @@ pub enum Error {
12961294
},
12971295

12981296
/// Error when an operation is not implemented
1299-
#[snafu(display("Operation not yet implemented."))]
1297+
#[error("Operation not yet implemented.")]
13001298
NotImplemented,
13011299

13021300
/// Error when the used credentials don't have enough permission
13031301
/// to perform the requested operation
1304-
#[snafu(display(
1302+
#[error(
13051303
"The operation lacked the necessary privileges to complete for path {}: {}",
13061304
path,
13071305
source
1308-
))]
1306+
)]
13091307
PermissionDenied {
13101308
/// The path to the file
13111309
path: String,
@@ -1314,11 +1312,11 @@ pub enum Error {
13141312
},
13151313

13161314
/// Error when the used credentials lack valid authentication
1317-
#[snafu(display(
1315+
#[error(
13181316
"The operation lacked valid authentication credentials for path {}: {}",
13191317
path,
13201318
source
1321-
))]
1319+
)]
13221320
Unauthenticated {
13231321
/// The path to the file
13241322
path: String,
@@ -1327,7 +1325,7 @@ pub enum Error {
13271325
},
13281326

13291327
/// Error when a configuration key is invalid for the store used
1330-
#[snafu(display("Configuration key: '{}' is not valid for store '{}'.", key, store))]
1328+
#[error("Configuration key: '{}' is not valid for store '{}'.", key, store)]
13311329
UnknownConfigurationKey {
13321330
/// The object store used
13331331
store: &'static str,

0 commit comments

Comments
 (0)