How to handle invalid cert when pinning Android with react native

Had searched around and successfully pinned the cert in Android.

However the app crashes if you provide an invalid key.

Is there a way to handle it more gracefully?

Am using the network_security_config

<?xml version="1.0" encoding="utf-8"?>
       <domain includeSubdomains="true"></domain>
           <pin digest="SHA-256">ZC3lTYTDBJQVf1P2V7+fibTqbIsWNR/X7CWNVW+CEEA=</pin>
           <pin digest="SHA-256">GUAL5bejH7czkXcAeJ0vCiRxwMnVBsDlBMBsFtfLF8A=</pin>

example from this post:

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum