refactor(tts): remove InputError class and use native Error
This commit is contained in:
parent
710d2e7593
commit
fc7d9101e9
1 changed files with 2 additions and 8 deletions
10
tts.ts
10
tts.ts
|
|
@ -12,10 +12,6 @@ import { execa } from "execa";
|
||||||
import { Window } from "happy-dom";
|
import { Window } from "happy-dom";
|
||||||
import wrapAnsi from "wrap-ansi";
|
import wrapAnsi from "wrap-ansi";
|
||||||
|
|
||||||
class InputError extends Error {
|
|
||||||
override name = "InputError";
|
|
||||||
}
|
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
|
|
||||||
|
|
@ -48,9 +44,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!input) {
|
if (!input) {
|
||||||
throw new InputError(
|
throw new Error("No input was given. Use positional arguments or stdin.");
|
||||||
"No input was given. Use positional arguments or stdin.",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
|
|
@ -61,7 +55,7 @@ async function main() {
|
||||||
await window.happyDOM.waitUntilComplete();
|
await window.happyDOM.waitUntilComplete();
|
||||||
const readable = new Readability(doc).parse();
|
const readable = new Readability(doc).parse();
|
||||||
if (!readable?.textContent) {
|
if (!readable?.textContent) {
|
||||||
throw new InputError(
|
throw new Error(
|
||||||
"Unable to read webpage. This usually means it's blocking scrapers.",
|
"Unable to read webpage. This usually means it's blocking scrapers.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue