Skip to content

Commit

Permalink
feat: Mk:apiが失敗時エラー型の値を返すように (#2) (#11843)
Browse files Browse the repository at this point in the history
* Mk:apiが失敗時エラー型の値を返すように (#2)

* Update CHANGELOG.md
  • Loading branch information
FineArchs committed Sep 18, 2023
1 parent aa80cfd commit 44985ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- Playの操作を行うAPI TokenをAPIコンソールから発行できるように
- リアクションの表示サイズをより大きくできるように
- AiScriptを0.16.0に更新
- Mk:apiが失敗した時にエラー型の値(AiScript 0.16.0で追加)を返すように
- タイムラインでリスト/アンテナ選択時のパフォーマンスを改善
- 「Moderation note」、「Add moderation note」をローカライズできるように
- 新しい実績を追加
Expand Down
7 changes: 5 additions & 2 deletions packages/frontend/src/scripts/aiscript/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ export function createAiScriptEnv(opts) {
// バグがあればundefinedもあり得るため念のため
if (typeof token.value !== 'string') throw new Error('invalid token');
}
const res = await os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token ?? null));
return utils.jsToVal(res);
return os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token ?? null)).then(res => {
return utils.jsToVal(res);
}, err => {
return values.ERROR('request_failed', utils.jsToVal(err));
});
}),
'Mk:save': values.FN_NATIVE(([key, value]) => {
utils.assertString(key);
Expand Down

0 comments on commit 44985ae

Please sign in to comment.