MB34
MB34

Reputation: 4434

Does PerformImmediateLogin throw a custom exception? If so, what is the type?

When calling we'd like to be able to catch any exceptions in a try catch and hand over to our handler.

IVaultClient vaultClient = new VaultClient(vaultClientSettings);
try {
    vaultClient.V1.Auth.PerformImmediateLogin();
} catch ( Exception e) {
}

Upvotes: 1

Views: 63

Answers (1)

Raja Nadar
Raja Nadar

Reputation: 9499

Yes, in general, all VaultSharp APIs tend to throw this custom exception.

VaultApiException

See here for the fields.

https://github.com/rajanadar/VaultSharp/blob/master/src/VaultSharp/Core/VaultApiException.cs

However, the PerformImmediateLogin can also throw the Exception type when the HTTP login call to Vault does succeed but the response has an empty AuthInfo object (thus not giving back a vault token). This may or may not happen in real life, but this is the only case where Exception is thrown. Otherwise, you can always expect VaultSharp to throw the VaultApiException type.

Upvotes: 0

Related Questions