diff options
author | Matthew Miller <matthew@millerti.me> | 2020-06-02 16:02:10 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2020-06-02 16:02:10 -0700 |
commit | 89ee6ac9ce1e63514d74b75a1bdf0ef4200ca459 (patch) | |
tree | d520464bda0f2a9fa6e50573c16df9a3cd36274d | |
parent | e125f8f03924ae8263cffd426db29b5a815df0f1 (diff) |
Update Register page to expose friendlier error
Assuming the libraries are doing their thing properly, `InvalidStateError` comes up most often when a user attempts to perform attestation with a credential they’ve already registered.
Unfortunately `InvalidStateError` as defined in the spec seems throwable under a few other circumstances, hence the vagueness of the error message here.
-rw-r--r-- | example/public/register/index.html | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/example/public/register/index.html b/example/public/register/index.html index 05d7ef5..c8f0fa1 100644 --- a/example/public/register/index.html +++ b/example/public/register/index.html @@ -36,8 +36,13 @@ try { attResp = await startAttestation(await resp.json()); } catch (error) { - elemError.innerText = error; - throw new Error(error); + if (error.name === 'InvalidStateError') { + elemError.innerText = 'Error: Authenticator was probably already registered by user'; + } else { + elemError.innerText = error; + } + + throw error; } const verificationResp = await fetch('/verify-attestation', { |