Skip to content

Commit ac57247

Browse files
committed
Update all other platforms with the new error mechanism
1 parent 9463692 commit ac57247

File tree

6 files changed

+52
-32
lines changed

6 files changed

+52
-32
lines changed

src/freebsd/transaction.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use crate::errors;
56
use crate::platform::monitor::Monitor;
67
use crate::statecallback::StateCallback;
78
use runloop::RunLoop;
@@ -15,9 +16,9 @@ pub struct Transaction {
1516
impl Transaction {
1617
pub fn new<F, T>(
1718
timeout: u64,
18-
callback: StateCallback<Result<T, crate::Error>>,
19+
callback: StateCallback<crate::Result<T>>,
1920
new_device_cb: F,
20-
) -> Result<Self, crate::Error>
21+
) -> crate::Result<Self>
2122
where
2223
F: Fn(OsString, &dyn Fn() -> bool) + Sync + Send + 'static,
2324
T: 'static,
@@ -29,14 +30,16 @@ impl Transaction {
2930

3031
// Start polling for new devices.
3132
try_or!(monitor.run(alive), |_| callback
32-
.call(Err(crate::Error::Unknown)));
33+
.call(Err(errors::AuthenticatorError::Platform)));
3334

3435
// Send an error, if the callback wasn't called already.
35-
callback.call(Err(crate::Error::NotAllowed));
36+
callback.call(Err(errors::AuthenticatorError::U2FToken(
37+
errors::U2FTokenError::NotAllowed,
38+
)));
3639
},
3740
timeout,
3841
)
39-
.map_err(|_| crate::Error::Unknown)?;
42+
.map_err(|_| errors::AuthenticatorError::Platform)?;
4043

4144
Ok(Self {
4245
thread: Some(thread),

src/linux/transaction.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use crate::errors;
56
use crate::platform::monitor::Monitor;
67
use crate::statecallback::StateCallback;
78
use runloop::RunLoop;
@@ -15,9 +16,9 @@ pub struct Transaction {
1516
impl Transaction {
1617
pub fn new<F, T>(
1718
timeout: u64,
18-
callback: StateCallback<Result<T, crate::Error>>,
19+
callback: StateCallback<crate::Result<T>>,
1920
new_device_cb: F,
20-
) -> Result<Self, crate::Error>
21+
) -> crate::Result<Self>
2122
where
2223
F: Fn(OsString, &dyn Fn() -> bool) + Sync + Send + 'static,
2324
T: 'static,
@@ -29,14 +30,16 @@ impl Transaction {
2930

3031
// Start polling for new devices.
3132
try_or!(monitor.run(alive), |_| callback
32-
.call(Err(crate::Error::Unknown)));
33+
.call(Err(errors::AuthenticatorError::Platform)));
3334

3435
// Send an error, if the callback wasn't called already.
35-
callback.call(Err(crate::Error::NotAllowed));
36+
callback.call(Err(errors::AuthenticatorError::U2FToken(
37+
errors::U2FTokenError::NotAllowed,
38+
)));
3639
},
3740
timeout,
3841
)
39-
.map_err(|_| crate::Error::Unknown)?;
42+
.map_err(|_| errors::AuthenticatorError::Platform)?;
4043

4144
Ok(Self {
4245
thread: Some(thread),

src/netbsd/transaction.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use crate::statecallback::StateCallback;
6-
use runloop::RunLoop;
7-
5+
use crate::errors;
86
use crate::platform::fd::Fd;
97
use crate::platform::monitor::Monitor;
8+
use crate::statecallback::StateCallback;
9+
use runloop::RunLoop;
1010

1111
pub struct Transaction {
1212
// Handle to the thread loop.
@@ -16,9 +16,9 @@ pub struct Transaction {
1616
impl Transaction {
1717
pub fn new<F, T>(
1818
timeout: u64,
19-
callback: StateCallback<Result<T, crate::Error>>,
19+
callback: StateCallback<crate::Result<T>>,
2020
new_device_cb: F,
21-
) -> Result<Self, crate::Error>
21+
) -> crate::Result<Self>
2222
where
2323
F: Fn(Fd, &dyn Fn() -> bool) + Sync + Send + 'static,
2424
T: 'static,
@@ -30,14 +30,16 @@ impl Transaction {
3030

3131
// Start polling for new devices.
3232
try_or!(monitor.run(alive), |_| callback
33-
.call(Err(crate::Error::Unknown)));
33+
.call(Err(errors::AuthenticatorError::Platform)));
3434

3535
// Send an error, if the callback wasn't called already.
36-
callback.call(Err(crate::Error::NotAllowed));
36+
callback.call(Err(errors::AuthenticatorError::U2FToken(
37+
errors::U2FTokenError::NotAllowed,
38+
)));
3739
},
3840
timeout,
3941
)
40-
.map_err(|_| crate::Error::Unknown)?;
42+
.map_err(|_| errors::AuthenticatorError::Platform)?;
4143

4244
Ok(Self {
4345
thread: Some(thread),

src/openbsd/transaction.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use crate::errors;
56
use crate::platform::monitor::{FidoDev, Monitor};
67
use crate::statecallback::StateCallback;
78
use runloop::RunLoop;
@@ -14,9 +15,9 @@ pub struct Transaction {
1415
impl Transaction {
1516
pub fn new<F, T>(
1617
timeout: u64,
17-
callback: StateCallback<Result<T, crate::Error>>,
18+
callback: StateCallback<crate::Result<T>>,
1819
new_device_cb: F,
19-
) -> Result<Self, crate::Error>
20+
) -> crate::Result<Self>
2021
where
2122
F: Fn(FidoDev, &dyn Fn() -> bool) + Sync + Send + 'static,
2223
T: 'static,
@@ -28,14 +29,16 @@ impl Transaction {
2829

2930
// Start polling for new devices.
3031
try_or!(monitor.run(alive), |_| callback
31-
.call(Err(crate::Error::Unknown)));
32+
.call(Err(errors::AuthenticatorError::Platform)));
3233

3334
// Send an error, if the callback wasn't called already.
34-
callback.call(Err(crate::Error::NotAllowed));
35+
callback.call(Err(errors::AuthenticatorError::U2FToken(
36+
errors::U2FTokenError::NotAllowed,
37+
)));
3538
},
3639
timeout,
3740
)
38-
.map_err(|_| crate::Error::Unknown)?;
41+
.map_err(|_| errors::AuthenticatorError::Platform)?;
3942

4043
Ok(Self {
4144
thread: Some(thread),

src/stub/transaction.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use crate::errors;
56
use crate::statecallback::StateCallback;
67

78
pub struct Transaction {}
89

910
impl Transaction {
1011
pub fn new<F, T>(
1112
timeout: u64,
12-
callback: StateCallback<Result<T, crate::Error>>,
13+
callback: StateCallback<crate::Result<T>>,
1314
new_device_cb: F,
14-
) -> Result<Self, crate::Error>
15+
) -> crate::Result<Self>
1516
where
1617
F: Fn(String, &dyn Fn() -> bool),
1718
{
18-
callback.call(Err(crate::Error::NotSupported));
19-
Err(crate::Error::NotSupported)
19+
callback.call(Err(errors::AuthenticatorError::U2FToken(
20+
errors::U2FTokenError::NotSupported,
21+
)));
22+
23+
Err(errors::AuthenticatorError::U2FToken(
24+
errors::U2FTokenError::NotSupported,
25+
))
2026
}
2127

2228
pub fn cancel(&mut self) {

src/windows/transaction.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use crate::errors;
56
use crate::platform::monitor::Monitor;
67
use crate::statecallback::StateCallback;
78
use runloop::RunLoop;
@@ -14,9 +15,9 @@ pub struct Transaction {
1415
impl Transaction {
1516
pub fn new<F, T>(
1617
timeout: u64,
17-
callback: StateCallback<Result<T, crate::Error>>,
18+
callback: StateCallback<crate::Result<T>>,
1819
new_device_cb: F,
19-
) -> Result<Self, crate::Error>
20+
) -> crate::Result<Self>
2021
where
2122
F: Fn(String, &dyn Fn() -> bool) + Sync + Send + 'static,
2223
T: 'static,
@@ -28,14 +29,16 @@ impl Transaction {
2829

2930
// Start polling for new devices.
3031
try_or!(monitor.run(alive), |_| callback
31-
.call(Err(crate::Error::Unknown)));
32+
.call(Err(errors::AuthenticatorError::Platform)));
3233

3334
// Send an error, if the callback wasn't called already.
34-
callback.call(Err(crate::Error::NotAllowed));
35+
callback.call(Err(errors::AuthenticatorError::U2FToken(
36+
errors::U2FTokenError::NotAllowed,
37+
)));
3538
},
3639
timeout,
3740
)
38-
.map_err(|_| crate::Error::Unknown)?;
41+
.map_err(|_| errors::AuthenticatorError::Platform)?;
3942

4043
Ok(Self {
4144
thread: Some(thread),

0 commit comments

Comments
 (0)