mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Remove e: any from error handlers
This commit is contained in:
parent
ebaf2b9c59
commit
4eb7ea2461
4 changed files with 9 additions and 9 deletions
|
|
@ -102,8 +102,8 @@ async function exportEvents(args: ExportFilter) {
|
|||
let filter: NostrFilter = {};
|
||||
try {
|
||||
filter = buildFilter(args);
|
||||
} catch (e: any) {
|
||||
die(1, e.message || e.toString());
|
||||
} catch (e) {
|
||||
die(1, e instanceof Error ? e.message : e);
|
||||
}
|
||||
|
||||
let count = 0;
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ function connectStream(socket: WebSocket, ip: string | undefined) {
|
|||
for (const event of await store.query(filters, { limit: FILTER_LIMIT, timeout: Conf.db.timeouts.relay })) {
|
||||
send(['EVENT', subId, purifyEvent(event)]);
|
||||
}
|
||||
} catch (e: any) {
|
||||
} catch (e) {
|
||||
if (e instanceof RelayError) {
|
||||
send(['CLOSED', subId, e.message]);
|
||||
} else if (e.message.includes('timeout')) {
|
||||
} else if (e instanceof Error && e.message.includes('timeout')) {
|
||||
send(['CLOSED', subId, 'error: the relay could not respond fast enough']);
|
||||
} else {
|
||||
send(['CLOSED', subId, 'error: something went wrong']);
|
||||
|
|
|
|||
|
|
@ -76,10 +76,10 @@ class EventsDB extends NPostgres {
|
|||
|
||||
try {
|
||||
await super.event(event, { ...opts, timeout: opts.timeout ?? this.opts.timeout });
|
||||
} catch (e: any) {
|
||||
if (e.message === 'Cannot add a deleted event') {
|
||||
} catch (e) {
|
||||
if (e instanceof Error && e.message === 'Cannot add a deleted event') {
|
||||
throw new RelayError('blocked', 'event deleted by user');
|
||||
} else if (e.message === 'Cannot replace an event with an older event') {
|
||||
} else if (e instanceof Error && e.message === 'Cannot replace an event with an older event') {
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ export async function updateTrendingTags(
|
|||
|
||||
await handleEvent(label, signal);
|
||||
console.info(`Trending ${l} updated.`);
|
||||
} catch (e: any) {
|
||||
console.error(`Error updating trending ${l}: ${e.message}`);
|
||||
} catch (e) {
|
||||
console.error(`Error updating trending ${l}: ${e instanceof Error ? e.message : e}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue