-
I have a question regarding the ThrowsOnError parameter used in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @ Mrizzi-96, yes this is the expected behavior If you want to access the failure details in order to give additional details to the user, you can access the same properties normally included in the result, catching specific exception types. try
{
var result = await dgcReader.VerifyForItaly(qrCode, mode, throwOnError: true);
}
catch (DgcSignatureValidationException e)
{
var signatureResult = e.Result; // This is of type SignatureValidationResult
// signatureResult == result.Signature
// e.g:
Console.WriteLine($"Invalid signature for KID {e.Result.CertificateKid}");
}
catch (DgcBlackListException e)
{
var blacklistResult = e.Result; // This is of type BlacklistValidationResult
// blacklistResult == result.Blacklist
}
catch (DgcRulesValidationException e)
{
var validationResult = e.ValidationResult; // This is of type IRulesValidationResult
// validationResult == result.RulesValidation
var status = e.Status; // <-- HERE YOU CAN ACCESS THE VALIDATION STATUS
// More specific:
var italianResult = validationResult.AsItalianValidationResult();
if (italianResult != null)
{
Console.WriteLine(italianResult.ItalianStatus);
Console.WriteLine(italianResult.StatusMessage);
}
}
catch (DgcException e)
{
// Every exception thrown by DgcReader is of type DgcException, even the previous one inherits from this base type.
// So if you use a global error handler, you can catch DgcException to intercept validation errors thrown by the library
Console.WriteLine(e);
} |
Beta Was this translation helpful? Give feedback.
Hi @ Mrizzi-96, yes this is the expected behavior
Usually, exceptions regarding failed updates are not thrown until the files reaches MaxFileAge, in order to allow the validation to be completed if the service is temporarly unavailable for whatever reason.
When throwOnError is true, every mandatory step in validation will throw an exception, because validation at that point is already completed with a failure, or because a technical problem is preventing the execution of the required steps (e.g. values are not present and can not be downloaded, or have past MaxFileAge)
If you want to access the failure details in order to give additional details to the user, you can access the same proper…