Skip to content

Commit a910dda

Browse files
committed
chore: move word gen error definition to utils to fix circular dependency
1 parent 0bd49db commit a910dda

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

frontend/src/ts/test/funbox/funbox-functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { getSection } from "../wikipedia";
2222
import * as WeakSpot from "../weak-spot";
2323
import * as IPAddresses from "../../utils/ip-addresses";
2424
import * as TestState from "../test-state";
25-
import { WordGenError } from "../words-generator";
25+
import { WordGenError } from "../../utils/word-gen-error";
2626

2727
export type FunboxFunctions = {
2828
getWord?: (wordset?: Wordset, wordIndex?: number) => string;

frontend/src/ts/test/test-logic.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {
7373
import { getFunboxesFromString } from "@monkeytype/funbox";
7474
import * as CompositionState from "../states/composition";
7575
import { SnapshotResult } from "../constants/default-snapshot";
76+
import { WordGenError } from "../utils/word-gen-error";
7677

7778
let failReason = "";
7879
const koInputVisual = document.getElementById("koInputVisual") as HTMLElement;
@@ -469,7 +470,7 @@ export async function init(): Promise<void> {
469470
wordsHaveNewline = gen.hasNewline;
470471
} catch (e) {
471472
console.error(e);
472-
if (e instanceof WordsGenerator.WordGenError) {
473+
if (e instanceof WordGenError) {
473474
if (e.message.length > 0) {
474475
Notifications.add(e.message, 0, {
475476
important: true,

frontend/src/ts/test/words-generator.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getActiveFunboxesWithFunction,
2323
isFunboxActiveWithFunction,
2424
} from "./funbox/list";
25+
import { WordGenError } from "../utils/word-gen-error";
2526

2627
function shouldCapitalize(lastChar: string): boolean {
2728
return /[?!.؟]/.test(lastChar);
@@ -475,13 +476,6 @@ export function getLimit(): number {
475476
return limit;
476477
}
477478

478-
export class WordGenError extends Error {
479-
constructor(message: string) {
480-
super(message);
481-
this.name = "WordGenError";
482-
}
483-
}
484-
485479
async function getQuoteWordList(
486480
language: LanguageObject,
487481
wordOrder?: FunboxWordOrder
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export class WordGenError extends Error {
2+
constructor(message: string) {
3+
super(message);
4+
this.name = "WordGenError";
5+
}
6+
}

0 commit comments

Comments
 (0)