From 41d3b16029a9ef1bea386951b894ed6da3fc081f Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Fri, 30 Apr 2021 15:35:41 +0200 Subject: [PATCH] Ensure an output of the verification process --- src/claim.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/claim.js b/src/claim.js index c03c0a4..558d440 100644 --- a/src/claim.js +++ b/src/claim.js @@ -213,7 +213,7 @@ class Claim { for (let index = 0; index < this._matches.length; index++) { const claimData = this._matches[index] - let verificationResult, + let verificationResult = null, proofData = null, proofFetchError @@ -235,18 +235,18 @@ class Claim { viaProxy: proofData.viaProxy, } } else { - if (this.isAmbiguous()) { - // Assume a wrong match and continue - continue - } - // Consider the proof completed but with a negative result - verificationResult = { + verificationResult = verificationResult ? verificationResult : { result: false, completed: true, proof: {}, errors: [proofFetchError], } + + if (this.isAmbiguous()) { + // Assume a wrong match and continue + continue + } } if (verificationResult.completed) { @@ -257,6 +257,14 @@ class Claim { } } + // Fail safe verification result + verificationResult = verificationResult ? verificationResult : { + result: false, + completed: true, + proof: {}, + errors: ['Unknown error'], + } + this._status = E.ClaimStatus.VERIFIED }