mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
refactor(ext/fs): align error messages (#25414)
Aligns the error messages in the ext/fs folder to be in-line with the Deno style guide.
This commit is contained in:
parent
3553aa9132
commit
8626ec7c25
2 changed files with 12 additions and 8 deletions
|
@ -578,7 +578,7 @@ class FsFile {
|
|||
this.#rid = rid;
|
||||
if (!symbol || symbol !== SymbolFor("Deno.internal.FsFile")) {
|
||||
throw new TypeError(
|
||||
"`Deno.FsFile` cannot be constructed, use `Deno.open()` or `Deno.openSync()` instead.",
|
||||
"'Deno.FsFile' cannot be constructed, use 'Deno.open()' or 'Deno.openSync()' instead",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -713,11 +713,15 @@ function checkOpenOptions(options) {
|
|||
(val) => val === true,
|
||||
).length === 0
|
||||
) {
|
||||
throw new Error("OpenOptions requires at least one option to be true");
|
||||
throw new Error(
|
||||
"'options' requires at least one option to be true",
|
||||
);
|
||||
}
|
||||
|
||||
if (options.truncate && !options.write) {
|
||||
throw new Error("'truncate' option requires 'write' option");
|
||||
throw new Error(
|
||||
"'truncate' option requires 'write' to be true",
|
||||
);
|
||||
}
|
||||
|
||||
const createOrCreateNewWithoutWriteOrAppend =
|
||||
|
@ -726,7 +730,7 @@ function checkOpenOptions(options) {
|
|||
|
||||
if (createOrCreateNewWithoutWriteOrAppend) {
|
||||
throw new Error(
|
||||
"'create' or 'createNew' options require 'write' or 'append' option",
|
||||
"'create' or 'createNew' options require 'write' or 'append' to be true",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { write: false });
|
||||
},
|
||||
Error,
|
||||
"OpenOptions requires at least one option to be true",
|
||||
"'options' requires at least one option to be true",
|
||||
);
|
||||
|
||||
await assertRejects(
|
||||
|
@ -145,7 +145,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { truncate: true, write: false });
|
||||
},
|
||||
Error,
|
||||
"'truncate' option requires 'write' option",
|
||||
"'truncate' option requires 'write' to be true",
|
||||
);
|
||||
|
||||
await assertRejects(
|
||||
|
@ -153,7 +153,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { create: true, write: false });
|
||||
},
|
||||
Error,
|
||||
"'create' or 'createNew' options require 'write' or 'append' option",
|
||||
"'create' or 'createNew' options require 'write' or 'append' to be true",
|
||||
);
|
||||
|
||||
await assertRejects(
|
||||
|
@ -161,7 +161,7 @@ Deno.test(async function openOptions() {
|
|||
await Deno.open(filename, { createNew: true, append: false });
|
||||
},
|
||||
Error,
|
||||
"'create' or 'createNew' options require 'write' or 'append' option",
|
||||
"'create' or 'createNew' options require 'write' or 'append' to be true",
|
||||
);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue