Reference · Look words up by reading, written form, English meaning, kanji or romaji
WordsLoadErrorclass
What a lookup rejects with when a piece of the dictionary cannot be fetched, after one retry: a network that is down, a file the
host does not serve, a bundler that left the piece out. It names the piece, so a log says which one, and keeps the reason in
cause. Nothing else a lookup does rejects with it: a text with no word is an empty answer, and a lookup before loading is a
RangeError.
Import it
import { WordsLoadError } from "@johnmorrisdotca/jisho/words";
Definition
class WordsLoadError
new WordsLoadError(kind: WordsPieceKind, index: number | undefined, of: number | undefined, cause: unknown): WordsLoadError
Parameters
| Name | Type | Description |
|---|---|---|
kind | WordsPieceKind | Which set of pieces it was. |
index | number | undefined | The number of the piece in its set, if the set is cut in pieces. |
of | number | undefined | How many pieces the set has. |
cause | unknown | What the fetch rejected with. |
Members
| Name | Type | Description |
|---|---|---|
kind | WordsPieceKind | Which set of pieces it was. |
index | number | undefined | The number of the piece in its set, counting from 0; absent for a table or manifest that is one file. |
piece | string | The piece, in words: |
name | string | |
message | string | |
stack (optional) | string | undefined | |
cause (optional) | unknown |
Examples
import { loadWords, WordsLoadError } from "@johnmorrisdotca/jisho/words";
try {
await loadWords("かみ");
} catch (error) {
if (error instanceof WordsLoadError) console.log(error.kind, error.index, error.cause);
}