mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-02 11:37:44 +08:00
chore: move word gen error definition to utils to fix circular dependency
This commit is contained in:
parent
0bd49db8e5
commit
a910ddab47
4 changed files with 10 additions and 9 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
6
frontend/src/ts/utils/word-gen-error.ts
Normal file
6
frontend/src/ts/utils/word-gen-error.ts
Normal file
|
@ -0,0 +1,6 @@
|
|||
export class WordGenError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
this.name = "WordGenError";
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue