Skip to content

Commit b56bf22

Browse files
hsy822Aniket-Engg
authored andcommitted
error handling
1 parent d9f04de commit b56bf22

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

apps/contract-verification/src/app/ContractVerificationPluginClient.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,17 @@ export class ContractVerificationPluginClient extends PluginClient {
249249
}
250250

251251
} catch (error: any) {
252-
const errorMsg = error.message || 'Unknown error'
252+
let errorMsg = error.message || 'Unknown error'
253+
254+
if (errorMsg.trim().startsWith('<') || errorMsg.includes('<!DOCTYPE html>')) {
255+
errorMsg = 'Explorer API returned an Internal Server Error (500). Service might be unstable.';
256+
}
253257

254258
await this.updateReceiptStatus(contractId, verifierId, {
255259
status: 'failed',
256260
message: errorMsg
257261
})
258262

259-
// [Aniket Feedback]: 에러 메시지 그대로 출력
260263
await this.call('terminal', 'log', { type: 'error', value: `[${verifierId}] Verification Error: ${errorMsg}` })
261264
await this.call('terminal', 'log', { type: 'warn', value: `[${verifierId}] Please open the "Contract Verification" plugin to retry.` })
262265

apps/contract-verification/src/app/app.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,19 @@ const App = () => {
215215
}
216216
} catch (e) {
217217
receipt.failedChecks++
218+
219+
let errorMsg = e.message || 'Unknown error'
220+
221+
if (errorMsg.trim().startsWith('<') || errorMsg.includes('<!DOCTYPE html>')) {
222+
errorMsg = 'Explorer API Error (500)'
223+
}
224+
225+
// Only retry 10 times
218226
if (receipt.failedChecks >= 10) {
219227
receipt.status = 'failed'
220-
receipt.message = e.message
221-
plugin.call('terminal', 'log', { type: 'warn', value: `[${verifierInfo.name}] Verification Failed after ${receipt.failedChecks} attempts: ${e.message}` })
228+
receipt.message = errorMsg
229+
230+
plugin.call('terminal', 'log', { type: 'warn', value: `[${verifierInfo.name}] Verification Failed after ${receipt.failedChecks} attempts: ${errorMsg}` })
222231
plugin.call('terminal', 'log', { type: 'warn', value: `Please open the "Contract Verification" plugin to retry.` })
223232

224233
if (verifierInfo.name === 'Etherscan' && !chainSettings.verifiers['Etherscan']?.apiKey) {

0 commit comments

Comments
 (0)