Skip to content

Commit

Permalink
handle logMessage failing in ReportPoller timer
Browse files Browse the repository at this point in the history
  • Loading branch information
jesopo committed Aug 15, 2022
1 parent 21aabc8 commit 0c65a0c
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/report/ReportPoller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ export class ReportPoller {
"/_synapse/admin/v1/event_reports",
{ 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 @@ -87,8 +91,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 @@ -109,8 +117,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 @@ -120,8 +132,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

0 comments on commit 0c65a0c

Please sign in to comment.