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