chore: move word gen error definition to utils to fix circular dependency

This commit is contained in:
Miodec 2025-04-18 21:52:45 +02:00
parent 0bd49db8e5
commit a910ddab47
4 changed files with 10 additions and 9 deletions

View file

@ -22,7 +22,7 @@ import { getSection } from "../wikipedia";
import * as WeakSpot from "../weak-spot";
import * as IPAddresses from "../../utils/ip-addresses";
import * as TestState from "../test-state";
import { WordGenError } from "../words-generator";
import { WordGenError } from "../../utils/word-gen-error";
export type FunboxFunctions = {
getWord?: (wordset?: Wordset, wordIndex?: number) => string;

View file

@ -73,6 +73,7 @@ import {
import { getFunboxesFromString } from "@monkeytype/funbox";
import * as CompositionState from "../states/composition";
import { SnapshotResult } from "../constants/default-snapshot";
import { WordGenError } from "../utils/word-gen-error";
let failReason = "";
const koInputVisual = document.getElementById("koInputVisual") as HTMLElement;
@ -469,7 +470,7 @@ export async function init(): Promise<void> {
wordsHaveNewline = gen.hasNewline;
} catch (e) {
console.error(e);
if (e instanceof WordsGenerator.WordGenError) {
if (e instanceof WordGenError) {
if (e.message.length > 0) {
Notifications.add(e.message, 0, {
important: true,

View file

@ -22,6 +22,7 @@ import {
getActiveFunboxesWithFunction,
isFunboxActiveWithFunction,
} from "./funbox/list";
import { WordGenError } from "../utils/word-gen-error";
function shouldCapitalize(lastChar: string): boolean {
return /[?!.؟]/.test(lastChar);
@ -475,13 +476,6 @@ export function getLimit(): number {
return limit;
}
export class WordGenError extends Error {
constructor(message: string) {
super(message);
this.name = "WordGenError";
}
}
async function getQuoteWordList(
language: LanguageObject,
wordOrder?: FunboxWordOrder

View file

@ -0,0 +1,6 @@
export class WordGenError extends Error {
constructor(message: string) {
super(message);
this.name = "WordGenError";
}
}