From 4bac6fa310f85a439b8e269e17265e7f5cf85540 Mon Sep 17 00:00:00 2001 From: Francisco Date: Sun, 9 Jul 2023 18:36:23 -0300 Subject: [PATCH] Improve custom error helper when there is no match (#4437) --- test/helpers/customError.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/helpers/customError.js b/test/helpers/customError.js index e38170b78..ea5c36820 100644 --- a/test/helpers/customError.js +++ b/test/helpers/customError.js @@ -13,13 +13,10 @@ async function expectRevertCustomError(promise, expectedErrorName, args) { // VM Exception while processing transaction: // reverted with custom error 'InvalidAccountNonce("0x70997970C51812dc3A010C7d01b50e0d17dc79C8", 0)' - // We trim out anything inside the single quotes as comma-separated values - const [, error] = message.match(/'(.*)'/); - - // Attempt to parse as an error - const match = error.match(/(?\w+)\((?.*)\)/); + // Attempt to parse as a custom error + const match = message.match(/custom error '(?\w+)\((?.*)\)'/); if (!match) { - expect.fail(`Couldn't parse "${error}" as a custom error`); + expect.fail(`Could not parse as custom error. ${message}`); } // Extract the error name and parameters const errorName = match.groups.name;