From 1143504e005202cc9f4b72917d91cd4358d95b43 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Wed, 16 Oct 2024 19:19:07 +0900 Subject: [PATCH] revert some changes --- packages/frontend/src/scripts/misskey-api.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/frontend/src/scripts/misskey-api.ts b/packages/frontend/src/scripts/misskey-api.ts index 9087c7ac2c..1b1159fd01 100644 --- a/packages/frontend/src/scripts/misskey-api.ts +++ b/packages/frontend/src/scripts/misskey-api.ts @@ -14,7 +14,6 @@ export function misskeyApi< ResT = void, E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'], - ER extends Misskey.Endpoints[E]['errors'] = Misskey.Endpoints[E]['errors'], _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType : ResT, >( endpoint: E, @@ -48,15 +47,13 @@ export function misskeyApi< const body = res.status === 204 ? null : await res.json(); if (res.status === 200) { - resolve(body as _ResT); + resolve(body); } else if (res.status === 204) { resolve(undefined as _ResT); // void -> undefined } else { - reject(new Misskey.api.APIError(body.error)); + reject(body.error); } - }).catch((reason) => { - reject(new Error(reason)); - }); + }).catch(reject); }); promise.then(onFinally, onFinally); @@ -69,7 +66,6 @@ export function misskeyApiGet< ResT = void, E extends keyof Misskey.Endpoints = keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req'] = Misskey.Endpoints[E]['req'], - ER extends Misskey.Endpoints[E]['errors'] = Misskey.Endpoints[E]['errors'], _ResT = ResT extends void ? Misskey.api.SwitchCaseResponseType : ResT, >( endpoint: E, @@ -97,11 +93,9 @@ export function misskeyApiGet< } else if (res.status === 204) { resolve(undefined as _ResT); // void -> undefined } else { - reject(new Misskey.api.APIError(body.error)); + reject(body.error); } - }).catch((reason) => { - reject(new Error(reason)); - }); + }).catch(reject); }); promise.then(onFinally, onFinally);