Skip to content

Commit 1b688d1

Browse files
remove duplicate error handling
1 parent a898e92 commit 1b688d1

File tree

1 file changed

+2
-34
lines changed

1 file changed

+2
-34
lines changed

src/commands/protocols/publish/publish-finalization-command.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,7 @@ class PublishFinalizationCommand extends Command {
8484
const ual = this.ualService.deriveUAL(blockchain, contractAddress, id);
8585

8686
try {
87-
await this.validatePublishData(
88-
operationId,
89-
blockchain,
90-
merkleRoot,
91-
cachedMerkleRoot,
92-
byteSize,
93-
assertion,
94-
ual,
95-
);
87+
await this.validatePublishData(merkleRoot, cachedMerkleRoot, byteSize, assertion, ual);
9688
} catch (e) {
9789
this.logger.error(`Failed to validate publish data: ${e.message}`);
9890
this.operationIdService.emitChangeEvent(
@@ -173,26 +165,10 @@ class PublishFinalizationCommand extends Command {
173165
return Command.empty();
174166
}
175167

176-
async validatePublishData(
177-
operationId,
178-
blockchain,
179-
merkleRoot,
180-
cachedMerkleRoot,
181-
byteSize,
182-
assertion,
183-
ual,
184-
) {
168+
async validatePublishData(merkleRoot, cachedMerkleRoot, byteSize, assertion, ual) {
185169
if (merkleRoot !== cachedMerkleRoot) {
186170
const errorMessage = `Invalid Merkle Root for Knowledge Collection: ${ual}. Received value from blockchain: ${merkleRoot}, Cached value from publish operation: ${cachedMerkleRoot}`;
187171

188-
this.logger.error(`Command error (${this.errorType}): ${errorMessage}`);
189-
190-
this.operationIdService.emitChangeEvent(
191-
OPERATION_ID_STATUS.FAILED,
192-
operationId,
193-
blockchain,
194-
);
195-
196172
throw new Error(errorMessage);
197173
}
198174

@@ -203,14 +179,6 @@ class PublishFinalizationCommand extends Command {
203179
if (byteSize.toString() !== calculatedAssertionSize.toString()) {
204180
const errorMessage = `Invalid Assertion Size for Knowledge Collection: ${ual}. Received value from blockchain: ${byteSize}, Calculated value: ${calculatedAssertionSize}`;
205181

206-
this.logger.error(`Command error (${this.errorType}): ${errorMessage}`);
207-
208-
this.operationIdService.emitChangeEvent(
209-
OPERATION_ID_STATUS.FAILED,
210-
operationId,
211-
blockchain,
212-
);
213-
214182
throw new Error(errorMessage);
215183
}
216184
}

0 commit comments

Comments
 (0)