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 = {};
|
let filter: NostrFilter = {};
|
||||||
try {
|
try {
|
||||||
filter = buildFilter(args);
|
filter = buildFilter(args);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
die(1, e.message || e.toString());
|
die(1, e instanceof Error ? e.message : e);
|
||||||
}
|
}
|
||||||
|
|
||||||
let count = 0;
|
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 })) {
|
for (const event of await store.query(filters, { limit: FILTER_LIMIT, timeout: Conf.db.timeouts.relay })) {
|
||||||
send(['EVENT', subId, purifyEvent(event)]);
|
send(['EVENT', subId, purifyEvent(event)]);
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e instanceof RelayError) {
|
if (e instanceof RelayError) {
|
||||||
send(['CLOSED', subId, e.message]);
|
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']);
|
send(['CLOSED', subId, 'error: the relay could not respond fast enough']);
|
||||||
} else {
|
} else {
|
||||||
send(['CLOSED', subId, 'error: something went wrong']);
|
send(['CLOSED', subId, 'error: something went wrong']);
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,10 @@ class EventsDB extends NPostgres {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await super.event(event, { ...opts, timeout: opts.timeout ?? this.opts.timeout });
|
await super.event(event, { ...opts, timeout: opts.timeout ?? this.opts.timeout });
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
if (e.message === 'Cannot add a deleted event') {
|
if (e instanceof Error && e.message === 'Cannot add a deleted event') {
|
||||||
throw new RelayError('blocked', 'event deleted by user');
|
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;
|
return;
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,8 @@ export async function updateTrendingTags(
|
||||||
|
|
||||||
await handleEvent(label, signal);
|
await handleEvent(label, signal);
|
||||||
console.info(`Trending ${l} updated.`);
|
console.info(`Trending ${l} updated.`);
|
||||||
} catch (e: any) {
|
} catch (e) {
|
||||||
console.error(`Error updating trending ${l}: ${e.message}`);
|
console.error(`Error updating trending ${l}: ${e instanceof Error ? e.message : e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue