Don't re-wrap DeviceIdAttestationExceptions

Instead of always wrapping errors in a DeviceIdAttestationException,
check to see if the underlying cause was originally a
DeviceIdAttestationException. If so, unwrap the cause and just re-throw
that, preserving the original error.

Bug: 183827468
Test: GtsGmsCoreSecurityTestApp
Change-Id: Iab78ccaff91dd1de615e1d2b18f709027aecd59e
This commit is contained in:
Seth Moore
2021-05-05 17:34:15 -07:00
parent 7a622ea7eb
commit c73fe01f16

View File

@@ -293,6 +293,11 @@ public abstract class AttestationUtils {
} catch (SecurityException e) {
throw e;
} catch (Exception e) {
// If a DeviceIdAttestationException was previously wrapped with some other type,
// let's throw the original exception instead of wrapping it yet again.
if (e.getCause() instanceof DeviceIdAttestationException) {
throw (DeviceIdAttestationException) e.getCause();
}
throw new DeviceIdAttestationException("Unable to perform attestation", e);
}
}