Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle logMessage failing in ReportPoller timer #354

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions src/report/ReportPoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ export class ReportPoller {
from: this.from.toString()
}
);
} catch (ex) {
await this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to poll events: ${ex}`);
} catch (ex1) {
try {
await this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to poll events: ${ex1}`);
} catch (ex2) {
// failed to log. what do?
}
return;
}

Expand All @@ -91,8 +95,12 @@ export class ReportPoller {
"GET",
`/_synapse/admin/v1/rooms/${report.room_id}/context/${report.event_id}?limit=1`
)).event;
} catch (ex) {
this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to get context: ${ex}`);
} catch (ex1) {
try {
this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to get context: ${ex1}`);
} catch (ex2) {
// failed to log. what do?
}
continue;
}

Expand All @@ -113,8 +121,12 @@ export class ReportPoller {
this.from = response.next_token;
try {
await this.mjolnir.client.setAccountData(REPORT_POLL_EVENT_TYPE, { from: response.next_token });
} catch (ex) {
await this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to update progress: ${ex}`);
} catch (ex1) {
try {
await this.mjolnir.logMessage(LogLevel.ERROR, "getAbuseReports", `failed to update progress: ${ex1}`);
} catch (ex2) {
// failed to log. what do?
}
}
}
}
Expand All @@ -124,8 +136,12 @@ export class ReportPoller {

try {
await this.getAbuseReports()
} catch (ex) {
await this.mjolnir.logMessage(LogLevel.ERROR, "tryGetAbuseReports", `failed to get abuse reports: ${ex}`);
} catch (ex1) {
try {
await this.mjolnir.logMessage(LogLevel.ERROR, "tryGetAbuseReports", `failed to get abuse reports: ${ex1}`);
} catch (ex2) {
// failed to log. what do?
}
}

this.schedulePoll();
Expand Down