Skip to content

Commit 52af0c6

Browse files
committed
refactor(credential): Switch to an Other constructor
1 parent 459cab9 commit 52af0c6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

credential/cargo-credential/src/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ pub enum Error {
3838
Unknown,
3939
}
4040

41+
impl Error {
42+
pub(crate) fn other(inner: BoxError) -> Self {
43+
Self::Other(inner)
44+
}
45+
}
46+
4147
impl StdError for Error {
4248
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
4349
match self {
@@ -86,7 +92,7 @@ impl From<anyhow::Error> for Error {
8692

8793
impl<T: StdError + Send + Sync + 'static> From<Box<T>> for Error {
8894
fn from(value: Box<T>) -> Self {
89-
Error::Other(value)
95+
Error::other(value)
9096
}
9197
}
9298

credential/cargo-credential/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub trait Credential {
226226

227227
/// Runs the credential interaction
228228
pub fn main(credential: impl Credential) {
229-
let result = doit(credential).map_err(|e| Error::Other(e));
229+
let result = doit(credential).map_err(|e| Error::other(e));
230230
if result.is_err() {
231231
serde_json::to_writer(std::io::stdout(), &result)
232232
.expect("failed to serialize credential provider error");

0 commit comments

Comments
 (0)