Skip to content

Commit 97bcef1

Browse files
committed
primitives - adapter - rename the Error and fix issue with sentry build
1 parent 4cf538c commit 97bcef1

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

adapter/src/dummy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use futures::future::{BoxFuture, FutureExt};
22
use primitives::adapter::{
3-
Adapter, AdapterError, AdapterErrorKind, AdapterResult, DummyAdapterOptions, Session,
3+
Adapter, AdapterErrorKind, AdapterResult, DummyAdapterOptions, Error as AdapterError, Session,
44
};
55
use primitives::channel_validator::ChannelValidator;
66
use primitives::config::Config;

adapter/src/ethereum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use parity_crypto::publickey::{
1212
public_to_address, recover, verify_address, Address, Message, Signature,
1313
};
1414
use primitives::{
15-
adapter::{Adapter, AdapterError, AdapterResult, KeystoreOptions, Session},
15+
adapter::{Adapter, AdapterResult, Error as AdapterError, KeystoreOptions, Session},
1616
channel_validator::ChannelValidator,
1717
config::Config,
1818
Channel, ChannelId, ToETHChecksum, ValidatorId,

primitives/src/adapter.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ use futures::future::BoxFuture;
55
use serde::{Deserialize, Serialize};
66
use std::collections::HashMap;
77
use std::convert::From;
8-
use std::error::Error;
98
use std::fmt;
109

11-
pub type AdapterResult<T, AE> = Result<T, AdapterError<AE>>;
10+
pub type AdapterResult<T, AE> = Result<T, Error<AE>>;
1211

1312
pub trait AdapterErrorKind: fmt::Debug + fmt::Display {}
1413

1514
#[derive(Debug)]
16-
pub enum AdapterError<AE: AdapterErrorKind> {
15+
pub enum Error<AE: AdapterErrorKind> {
1716
Authentication(String),
1817
Authorization(String),
1918
Configuration(String),
@@ -27,33 +26,33 @@ pub enum AdapterError<AE: AdapterErrorKind> {
2726
LockedWallet,
2827
}
2928

30-
impl<AE: AdapterErrorKind> Error for AdapterError<AE> {}
29+
impl<AE: AdapterErrorKind> std::error::Error for Error<AE> {}
3130

32-
impl<AE: AdapterErrorKind> From<AE> for AdapterError<AE> {
31+
impl<AE: AdapterErrorKind> From<AE> for Error<AE> {
3332
fn from(adapter_err: AE) -> Self {
3433
Self::Adapter(adapter_err)
3534
}
3635
}
3736

38-
impl<AE: AdapterErrorKind> fmt::Display for AdapterError<AE> {
37+
impl<AE: AdapterErrorKind> fmt::Display for Error<AE> {
3938
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4039
match self {
41-
AdapterError::Authentication(error) => write!(f, "Authentication error: {}", error),
42-
AdapterError::Authorization(error) => write!(f, "Authorization error: {}", error),
43-
AdapterError::Configuration(error) => write!(f, "Configuration error: {}", error),
44-
AdapterError::Signature(error) => write!(f, "Signature error: {}", error),
45-
AdapterError::InvalidChannel(error) => write!(f, "{}", error),
46-
AdapterError::Failed(error) => write!(f, "error: {}", error),
47-
AdapterError::Adapter(error) => write!(f, "Adapter specific error: {}", error),
48-
AdapterError::Domain(error) => write!(f, "Domain error: {}", error),
49-
AdapterError::LockedWallet => write!(f, "You must `.unlock()` the wallet first"),
40+
Error::Authentication(error) => write!(f, "Authentication error: {}", error),
41+
Error::Authorization(error) => write!(f, "Authorization error: {}", error),
42+
Error::Configuration(error) => write!(f, "Configuration error: {}", error),
43+
Error::Signature(error) => write!(f, "Signature error: {}", error),
44+
Error::InvalidChannel(error) => write!(f, "{}", error),
45+
Error::Failed(error) => write!(f, "error: {}", error),
46+
Error::Adapter(error) => write!(f, "Adapter specific error: {}", error),
47+
Error::Domain(error) => write!(f, "Domain error: {}", error),
48+
Error::LockedWallet => write!(f, "You must `.unlock()` the wallet first"),
5049
}
5150
}
5251
}
5352

54-
impl<AE: AdapterErrorKind> From<DomainError> for AdapterError<AE> {
55-
fn from(err: DomainError) -> AdapterError<AE> {
56-
AdapterError::Domain(err)
53+
impl<AE: AdapterErrorKind> From<DomainError> for Error<AE> {
54+
fn from(err: DomainError) -> Error<AE> {
55+
Error::Domain(err)
5756
}
5857
}
5958

@@ -76,7 +75,7 @@ pub struct Session {
7675
}
7776

7877
pub trait Adapter: ChannelValidator + Send + Sync + Clone + fmt::Debug {
79-
type AdapterError: AdapterErrorKind;
78+
type AdapterError: AdapterErrorKind + 'static;
8079

8180
/// Unlock adapter
8281
fn unlock(&mut self) -> AdapterResult<(), Self::AdapterError>;

0 commit comments

Comments
 (0)