Produce more descriptive error for GenerateSasUri when using TokenCredential#23388
Conversation
| Argument.AssertNotNull(builder, nameof(builder)); | ||
| if (SharedKeyCredential == null) | ||
| { | ||
| throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential other than {nameof(TokenCredential)} in order to sign the SAS token."); |
There was a problem hiding this comment.
| throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential other than {nameof(TokenCredential)} in order to sign the SAS token."); | |
| throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires a credential that is not a {nameof(TokenCredential)} type in order to sign the SAS token."); |
There was a problem hiding this comment.
I'm not in love with the suggestion, honestly... but it took me a couple of reads of the original to understand that you're looking for a shared key-based credential.
There was a problem hiding this comment.
Yeah, I am not in love with what I originally wrote either. I wanted to be less specific than Shared Key, since Connection String auth also works. Although the shared key is also present there, it's not explicitly a SharedKeyCredential.
What I was trying to convey with the current message is roughly - "this will fail if you used the TokenCredential ctor"
There was a problem hiding this comment.
What do you think of this?
throw new InvalidOperationException($"{nameof(GenerateSasUri)} requires that this client be constructed with a credential type other than {nameof(TokenCredential)} in order to sign the SAS token.");
The current exception message thrown when attempting to call GenerateSasUri with a client constructed with a TokenCredential could be more descriptive.