Skip to content

Commit 44ef195

Browse files
committed
object_store/lib: Migrate from snafu to thiserror
1 parent fc2f78b commit 44ef195

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
@@ -563,7 +563,6 @@ use async_trait::async_trait;
563563
use bytes::Bytes;
564564
use chrono::{DateTime, Utc};
565565
use futures::{stream::BoxStream, StreamExt, TryStreamExt};
566-
use snafu::Snafu;
567566
use std::fmt::{Debug, Formatter};
568567
#[cfg(not(target_arch = "wasm32"))]
569568
use std::io::{Read, Seek, SeekFrom};
@@ -1224,11 +1223,11 @@ pub struct PutResult {
12241223
pub type Result<T, E = Error> = std::result::Result<T, E>;
12251224

12261225
/// A specialized `Error` for object store-related errors
1227-
#[derive(Debug, Snafu)]
1226+
#[derive(Debug, thiserror::Error)]
12281227
#[non_exhaustive]
12291228
pub enum Error {
12301229
/// A fallback error type when no variant matches
1231-
#[snafu(display("Generic {} error: {}", store, source))]
1230+
#[error("Generic {} error: {}", store, source)]
12321231
Generic {
12331232
/// The store this error originated from
12341233
store: &'static str,
@@ -1237,7 +1236,7 @@ pub enum Error {
12371236
},
12381237

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

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

12581255
/// Error when `tokio::spawn` failed
1259-
#[snafu(display("Error joining spawned task: {}", source), context(false))]
1256+
#[error("Error joining spawned task: {}", source)]
12601257
JoinError {
12611258
/// The wrapped error
1259+
#[from]
12621260
source: tokio::task::JoinError,
12631261
},
12641262

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

12721270
/// Error when the object already exists
1273-
#[snafu(display("Object at location {} already exists: {}", path, source))]
1271+
#[error("Object at location {} already exists: {}", path, source)]
12741272
AlreadyExists {
12751273
/// The path to the
12761274
path: String,
@@ -1279,7 +1277,7 @@ pub enum Error {
12791277
},
12801278

12811279
/// Error when the required conditions failed for the operation
1282-
#[snafu(display("Request precondition failure for path {}: {}", path, source))]
1280+
#[error("Request precondition failure for path {}: {}", path, source)]
12831281
Precondition {
12841282
/// The path to the file
12851283
path: String,
@@ -1288,7 +1286,7 @@ pub enum Error {
12881286
},
12891287

12901288
/// Error when the object at the location isn't modified
1291-
#[snafu(display("Object at location {} not modified: {}", path, source))]
1289+
#[error("Object at location {} not modified: {}", path, source)]
12921290
NotModified {
12931291
/// The path to the file
12941292
path: String,
@@ -1297,16 +1295,16 @@ pub enum Error {
12971295
},
12981296

12991297
/// Error when an operation is not implemented
1300-
#[snafu(display("Operation not yet implemented."))]
1298+
#[error("Operation not yet implemented.")]
13011299
NotImplemented,
13021300

13031301
/// Error when the used credentials don't have enough permission
13041302
/// to perform the requested operation
1305-
#[snafu(display(
1303+
#[error(
13061304
"The operation lacked the necessary privileges to complete for path {}: {}",
13071305
path,
13081306
source
1309-
))]
1307+
)]
13101308
PermissionDenied {
13111309
/// The path to the file
13121310
path: String,
@@ -1315,11 +1313,11 @@ pub enum Error {
13151313
},
13161314

13171315
/// Error when the used credentials lack valid authentication
1318-
#[snafu(display(
1316+
#[error(
13191317
"The operation lacked valid authentication credentials for path {}: {}",
13201318
path,
13211319
source
1322-
))]
1320+
)]
13231321
Unauthenticated {
13241322
/// The path to the file
13251323
path: String,
@@ -1328,7 +1326,7 @@ pub enum Error {
13281326
},
13291327

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

0 commit comments

Comments
 (0)