Openstatus www.openstatus.dev

Improve error handling (#1213)

* improve error handling

* improve error handling

authored by

Thibault Le Ouay and committed by
GitHub
6bf8d47e 46aaded7

+11 -5
+10 -5
apps/workflows/src/checker/index.ts
··· 84 84 .where( 85 85 and( 86 86 eq(schema.monitorStatusTable.monitorId, monitor.id), 87 - eq(schema.monitorStatusTable.status, status) 88 - ) 87 + eq(schema.monitorStatusTable.status, status), 88 + ), 89 89 ) 90 90 .get(); 91 91 ··· 103 103 and( 104 104 eq(incidentTable.monitorId, Number(monitorId)), 105 105 isNull(incidentTable.resolvedAt), 106 - isNull(incidentTable.acknowledgedAt) 107 - ) 106 + isNull(incidentTable.acknowledgedAt), 107 + ), 108 108 ) 109 109 .get(); 110 110 ··· 138 138 message, 139 139 notifType: "recovery", 140 140 cronTimestamp, 141 + region, 142 + latency, 141 143 incidentId: `${cronTimestamp}`, 142 144 }); 143 145 ··· 153 155 case "degraded": 154 156 if (monitor.status !== "degraded") { 155 157 console.log( 156 - `🔄 update monitorStatus ${monitor.id} status: DEGRADED}` 158 + `🔄 update monitorStatus ${monitor.id} status: DEGRADED}`, 157 159 ); 158 160 await db 159 161 .update(schema.monitor) ··· 167 169 notifType: "degraded", 168 170 cronTimestamp, 169 171 latency, 172 + region, 170 173 incidentId: `${cronTimestamp}`, 171 174 }); 172 175 } ··· 197 200 message, 198 201 notifType: "alert", 199 202 cronTimestamp, 203 + latency, 204 + region, 200 205 incidentId: String(newIncident[0].id), 201 206 }); 202 207
+1
apps/workflows/src/cron/monitor.ts
··· 288 288 .get(); 289 289 // We should only have one user :) 290 290 if (!users) { 291 + console.log(`No user found for ${userId}`); 291 292 throw new Error("Too many users found"); 292 293 } 293 294