diff options
author | Ian Bull <irbull@gmail.com> | 2024-09-04 00:19:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 09:19:55 +0200 |
commit | 939c23f9fe332797f4b2c8a80359fd36a3e7c105 (patch) | |
tree | c20c31bf6b95290e1b4bcaa83d087bd13a0eb902 /cli/js | |
parent | 072bf5d379b691c4decd3c167a51801bad8ca2f6 (diff) |
refactor(cli/js): align error messages (#25406)
Aligns the error messages in the cli/js folder to be in-line with the
Deno style guide.
Diffstat (limited to 'cli/js')
-rw-r--r-- | cli/js/40_bench.js | 16 | ||||
-rw-r--r-- | cli/js/40_test.js | 16 |
2 files changed, 16 insertions, 16 deletions
diff --git a/cli/js/40_bench.js b/cli/js/40_bench.js index a94c782fc..b07df3993 100644 --- a/cli/js/40_bench.js +++ b/cli/js/40_bench.js @@ -104,12 +104,12 @@ function bench( } if (optionsOrFn.fn != undefined) { throw new TypeError( - "Unexpected 'fn' field in options, bench function is already provided as the third argument.", + "Unexpected 'fn' field in options, bench function is already provided as the third argument", ); } if (optionsOrFn.name != undefined) { throw new TypeError( - "Unexpected 'name' field in options, bench name is already provided as the first argument.", + "Unexpected 'name' field in options, bench name is already provided as the first argument", ); } benchDesc = { @@ -141,7 +141,7 @@ function bench( fn = optionsOrFn; if (nameOrFnOrOptions.fn != undefined) { throw new TypeError( - "Unexpected 'fn' field in options, bench function is already provided as the second argument.", + "Unexpected 'fn' field in options, bench function is already provided as the second argument", ); } name = nameOrFnOrOptions.name ?? fn.name; @@ -150,7 +150,7 @@ function bench( !nameOrFnOrOptions.fn || typeof nameOrFnOrOptions.fn !== "function" ) { throw new TypeError( - "Expected 'fn' field in the first argument to be a bench function.", + "Expected 'fn' field in the first argument to be a bench function", ); } fn = nameOrFnOrOptions.fn; @@ -385,12 +385,12 @@ function createBenchContext(desc) { start() { if (currentBenchId !== desc.id) { throw new TypeError( - "The benchmark which this context belongs to is not being executed.", + "The benchmark which this context belongs to is not being executed", ); } if (currentBenchUserExplicitStart != null) { throw new TypeError( - "BenchContext::start() has already been invoked.", + "BenchContext::start() has already been invoked", ); } currentBenchUserExplicitStart = benchNow(); @@ -399,11 +399,11 @@ function createBenchContext(desc) { const end = benchNow(); if (currentBenchId !== desc.id) { throw new TypeError( - "The benchmark which this context belongs to is not being executed.", + "The benchmark which this context belongs to is not being executed", ); } if (currentBenchUserExplicitEnd != null) { - throw new TypeError("BenchContext::end() has already been invoked."); + throw new TypeError("BenchContext::end() has already been invoked"); } currentBenchUserExplicitEnd = end; }, diff --git a/cli/js/40_test.js b/cli/js/40_test.js index 5a081e217..ea526a17d 100644 --- a/cli/js/40_test.js +++ b/cli/js/40_test.js @@ -113,7 +113,7 @@ function assertExit(fn, isTest) { throw new Error( `${ isTest ? "Test case" : "Bench" - } finished with exit code set to ${exitCode}.`, + } finished with exit code set to ${exitCode}`, ); } if (innerResult) { @@ -242,12 +242,12 @@ function testInner( } if (optionsOrFn.fn != undefined) { throw new TypeError( - "Unexpected 'fn' field in options, test function is already provided as the third argument.", + "Unexpected 'fn' field in options, test function is already provided as the third argument", ); } if (optionsOrFn.name != undefined) { throw new TypeError( - "Unexpected 'name' field in options, test name is already provided as the first argument.", + "Unexpected 'name' field in options, test name is already provided as the first argument", ); } testDesc = { @@ -279,7 +279,7 @@ function testInner( fn = optionsOrFn; if (nameOrFnOrOptions.fn != undefined) { throw new TypeError( - "Unexpected 'fn' field in options, test function is already provided as the second argument.", + "Unexpected 'fn' field in options, test function is already provided as the second argument", ); } name = nameOrFnOrOptions.name ?? fn.name; @@ -288,7 +288,7 @@ function testInner( !nameOrFnOrOptions.fn || typeof nameOrFnOrOptions.fn !== "function" ) { throw new TypeError( - "Expected 'fn' field in the first argument to be a test function.", + "Expected 'fn' field in the first argument to be a test function", ); } fn = nameOrFnOrOptions.fn; @@ -426,7 +426,7 @@ function createTestContext(desc) { let stepDesc; if (typeof nameOrFnOrOptions === "string") { if (typeof maybeFn !== "function") { - throw new TypeError("Expected function for second argument."); + throw new TypeError("Expected function for second argument"); } stepDesc = { name: nameOrFnOrOptions, @@ -434,7 +434,7 @@ function createTestContext(desc) { }; } else if (typeof nameOrFnOrOptions === "function") { if (!nameOrFnOrOptions.name) { - throw new TypeError("The step function must have a name."); + throw new TypeError("The step function must have a name"); } if (maybeFn != undefined) { throw new TypeError( @@ -449,7 +449,7 @@ function createTestContext(desc) { stepDesc = nameOrFnOrOptions; } else { throw new TypeError( - "Expected a test definition or name and function.", + "Expected a test definition or name and function", ); } stepDesc.ignore ??= false; |