-
Notifications
You must be signed in to change notification settings - Fork 293
migrate azure_identity to azure_core::error::Error
#781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I had to show myself what fn calc(s: impl Into<String>){
s.into();
}
fn main() {
calc(format!("Hello, world!"));
} output from #![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
fn calc(s: impl Into<String>) {
s.into();
}
fn main() {
calc({
let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1(&["Hello, world!"], &[]));
res
});
} So yes, it is better to use a |
@@ -103,7 +109,7 @@ impl Error { | |||
} | |||
|
|||
/// Create an `Error` based on an error kind and some sort of message | |||
pub fn with_message<C>(kind: ErrorKind, message: C) -> Self | |||
pub fn message<C>(kind: ErrorKind, message: C) -> Self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More similar with ResultExt::context
@@ -115,6 +121,21 @@ impl Error { | |||
} | |||
} | |||
|
|||
/// Creates an `Error` based on an error kind and formatted message | |||
pub fn with_message<F, C>(kind: ErrorKind, message: F) -> Self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Takes a function like ResultExt::with_context
. What about naming message_fn
or event messagef
?
I'm happy with the current naming. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly questions/clarifications about ErrorKind
usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More ErrorKind
suggestions... In my previous review I only gave a few as I wanted to know whether you agreed with the suggested changes. These cover the whole PR. Again, all are just suggestions so take or leave as you wish.
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good - approved.
Changes:
thiserror
errors & replaces withazure_core::error::Error
identity::TokenCredential
get_token
switched toazure_core::error::Error
Error::with_message
to accept aFnOnce
likeResultExt::with_context
.Error::message
, similar toResultExt::context
.