リファレンス · 読み、表記、英語の意味、漢字、ローマ字から単語を引く
WordsLoadErrorクラス
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { WordsLoadError } from "@johnmorrisdotca/jisho/words";
定義
class WordsLoadError
new WordsLoadError(kind: WordsPieceKind, index: number | undefined, of: number | undefined, cause: unknown): WordsLoadError
引数
| 名前 | 型 | 説明 |
|---|---|---|
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. |
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
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 (省略可) | string | undefined | |
cause (省略可) | unknown |
例
import { loadWords, WordsLoadError } from "@johnmorrisdotca/jisho/words";
try {
await loadWords("かみ");
} catch (error) {
if (error instanceof WordsLoadError) console.log(error.kind, error.index, error.cause);
}この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。