@@ -186,37 +186,34 @@ async def get_events(self) -> list[Event]:
186
186
"""
187
187
Discover available events in the branding repository.
188
188
189
- Misconfigured events are skipped. May return an empty list in the catastrophic case .
189
+ Propagate errors if an event fails to fetch or deserialize .
190
190
"""
191
191
log .debug ("Discovering events in branding repository." )
192
192
193
- try :
194
- event_directories = await self .fetch_directory ("events" , types = ("dir" ,)) # Skip files.
195
- except Exception :
196
- log .exception ("Failed to fetch 'events' directory." )
197
- return []
193
+ event_directories = await self .fetch_directory ("events" , types = ("dir" ,)) # Skip files.
198
194
199
195
instances : list [Event ] = []
200
196
201
197
for event_directory in event_directories .values ():
202
- log .trace (f"Attempting to construct event from directory: '{ event_directory .path } '." )
203
- try :
204
- instance = await self .construct_event (event_directory )
205
- except Exception as exc :
206
- log .warning (f"Could not construct event '{ event_directory .path } '." , exc_info = exc )
207
- else :
208
- instances .append (instance )
198
+ log .trace (f"Reading event directory: '{ event_directory .path } '." )
199
+ instance = await self .construct_event (event_directory )
200
+ instances .append (instance )
209
201
210
202
return instances
211
203
212
- async def get_current_event (self ) -> tuple [Event | None , list [Event ]]:
204
+ async def get_current_event (self ) -> tuple [Event , list [Event ]]:
213
205
"""
214
206
Get the currently active event, or the fallback event.
215
207
216
208
The second return value is a list of all available events. The caller may discard it, if not needed.
217
209
Returning all events alongside the current one prevents having to query the API twice in some cases.
218
210
219
- The current event may be None in the case that no event is active, and no fallback event is found.
211
+ Raise an error in the following cases:
212
+ * GitHub request fails
213
+ * The branding repo contains an invalid event
214
+ * No event is active and the fallback event is missing
215
+
216
+ Events are validated in the branding repo. The bot assumes that events are valid.
220
217
"""
221
218
utc_now = datetime .now (tz = UTC )
222
219
log .debug (f"Finding active event for: { utc_now } ." )
@@ -249,5 +246,4 @@ async def get_current_event(self) -> tuple[Event | None, list[Event]]:
249
246
if event .meta .is_fallback :
250
247
return event , available_events
251
248
252
- log .warning ("No event is currently active and no fallback event was found!" )
253
- return None , available_events
249
+ raise BrandingMisconfigurationError ("No event is active and the fallback event is missing!" )
0 commit comments