@@ -115,72 +115,24 @@ fn get_authority_host(env: Option<Env>, option: Option<String>) -> Result<Url> {
115
115
const TSG_LINK_ERROR_TEXT : & str =
116
116
". To troubleshoot, visit https://aka.ms/azsdk/rust/identity/troubleshoot" ;
117
117
118
- /// A troubleshooting guide entry.
119
- #[ doc( hidden) ]
120
- pub trait TroubleshootingGuide : private:: Sealed {
121
- /// The URL fragment (leading '#' and an anchor) for this type's entry in the troubleshooting guide.
122
- const FRAGMENT : & ' static str ;
123
- }
124
-
125
- #[ cfg( not( target_arch = "wasm32" ) ) ]
126
- impl TroubleshootingGuide for AzureCliCredential {
127
- const FRAGMENT : & ' static str = "#azure-cli" ;
128
- }
129
-
130
- #[ cfg( not( target_arch = "wasm32" ) ) ]
131
- impl TroubleshootingGuide for AzureDeveloperCliCredential {
132
- const FRAGMENT : & ' static str = "#azd" ;
133
- }
134
-
135
- impl TroubleshootingGuide for AzurePipelinesCredential {
136
- const FRAGMENT : & ' static str = "#apc" ;
137
- }
138
-
139
- #[ cfg( feature = "client_certificate" ) ]
140
- impl TroubleshootingGuide for ClientCertificateCredential {
141
- const FRAGMENT : & ' static str = "#client-cert" ;
142
- }
143
-
144
- impl TroubleshootingGuide for ClientSecretCredential {
145
- const FRAGMENT : & ' static str = "#client-secret" ;
146
- }
147
-
148
- impl TroubleshootingGuide for ManagedIdentityCredential {
149
- const FRAGMENT : & ' static str = "#managed-id" ;
150
- }
151
-
152
- impl TroubleshootingGuide for WorkloadIdentityCredential {
153
- const FRAGMENT : & ' static str = "#workload" ;
154
- }
155
-
156
- mod private {
157
- pub trait Sealed { }
158
- #[ cfg( not( target_arch = "wasm32" ) ) ]
159
- impl Sealed for super :: AzureCliCredential { }
160
- #[ cfg( not( target_arch = "wasm32" ) ) ]
161
- impl Sealed for super :: AzureDeveloperCliCredential { }
162
- impl Sealed for super :: AzurePipelinesCredential { }
163
- #[ cfg( feature = "client_certificate" ) ]
164
- impl Sealed for super :: ClientCertificateCredential { }
165
- impl Sealed for super :: ClientSecretCredential { }
166
- impl Sealed for super :: ManagedIdentityCredential { }
167
- impl Sealed for super :: WorkloadIdentityCredential { }
168
- }
169
-
170
118
/// Map an error from a credential's get_token() method to an ErrorKind::Credential error, appending
171
119
/// a link to the troubleshooting guide entry for that credential, if it has one.
172
120
///
173
121
/// TODO: decide whether to map to ErrorKind::Credential here (https://github.com/Azure/azure-sdk-for-rust/issues/3127)
174
- fn authentication_error < T : TroubleshootingGuide + ' static > (
175
- e : azure_core:: Error ,
176
- ) -> azure_core:: Error {
122
+ fn authentication_error < T : ' static > ( e : azure_core:: Error ) -> azure_core:: Error {
177
123
azure_core:: Error :: with_message_fn ( e. kind ( ) . clone ( ) , || {
178
124
let type_name = std:: any:: type_name :: < T > ( ) ;
179
- let short_name = type_name. rsplit ( "::" ) . next ( ) . unwrap_or ( type_name) ;
180
- let link = if T :: FRAGMENT . is_empty ( ) {
181
- String :: new ( )
182
- } else {
183
- format ! ( "{TSG_LINK_ERROR_TEXT}{}" , T :: FRAGMENT )
125
+ let short_name = type_name. rsplit ( "::" ) . next ( ) . unwrap_or ( type_name) ; // cspell:ignore rsplit
126
+ let link = match short_name {
127
+ "AzureCliCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#azure-cli" ) ,
128
+ "AzureDeveloperCliCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#azd" ) ,
129
+ "AzurePipelinesCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#apc" ) ,
130
+ #[ cfg( feature = "client_certificate" ) ]
131
+ "ClientCertificateCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#client-cert" ) ,
132
+ "ClientSecretCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#client-secret" ) ,
133
+ "ManagedIdentityCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#managed-id" ) ,
134
+ "WorkloadIdentityCredential" => format ! ( "{TSG_LINK_ERROR_TEXT}#workload" ) ,
135
+ _ => "" . to_string ( ) ,
184
136
} ;
185
137
186
138
format ! ( "{short_name} authentication failed: {e}{link}" )
0 commit comments