From ab5124e851e34370279e6ac7741e8f9eda129285 Mon Sep 17 00:00:00 2001 From: "P. Reis" Date: Wed, 26 Feb 2025 20:21:42 -0300 Subject: [PATCH] refactor: return 500 http code in case of error --- packages/ditto/controllers/api/admin.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/ditto/controllers/api/admin.ts b/packages/ditto/controllers/api/admin.ts index d8d03eb9..f3611035 100644 --- a/packages/ditto/controllers/api/admin.ts +++ b/packages/ditto/controllers/api/admin.ts @@ -160,11 +160,12 @@ const adminActionController: AppController = async (c) => { } if (data.type === 'revoke_name') { n.revoke_name = true; - relay.remove?.([{ kinds: [30360], authors: [await conf.signer.getPublicKey()], '#p': [authorId] }]).catch( - (e: unknown) => { - logi({ level: 'error', ns: 'ditto.api.admin.account.action', type: data.type, error: errorJson(e) }); - }, - ); + try { + await relay.remove!([{ kinds: [30360], authors: [await conf.signer.getPublicKey()], '#p': [authorId] }]); + } catch (e) { + logi({ level: 'error', ns: 'ditto.api.admin.account.action', type: data.type, error: errorJson(e) }); + return c.json({ error: 'Unexpected runtime error' }, 500); + } } await updateUser(authorId, n, c);