Skip to content

Commit 837c0b1

Browse files
committed
fix: catch and log exceptions when updating OBS capture window
fixes #95
1 parent 22dbbbd commit 837c0b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

BF2AutoSpectator/spectate.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ def run():
132132

133133
if got_instance and config.control_obs():
134134
logger.debug('Found existing game window, updating OBS capture window')
135-
obsc.set_capture_window(config.get_obs_source_name(), constants.BF2_EXE, gim.game_window.title)
135+
try:
136+
obsc.set_capture_window(config.get_obs_source_name(), constants.BF2_EXE, gim.game_window.title)
137+
except Exception as e:
138+
logger.error(f'Failed to update OBS capture window: {e}')
136139
elif not got_instance:
137140
logger.info('Did not find any existing game instance, will launch a new one')
138141
gis.set_error_restart_required(True)
@@ -344,7 +347,10 @@ def run():
344347

345348
if got_instance and correct_params and config.control_obs():
346349
logger.debug('Game instance launched, updating OBS capture window')
347-
obsc.set_capture_window(config.get_obs_source_name(), constants.BF2_EXE, gim.game_window.title)
350+
try:
351+
obsc.set_capture_window(config.get_obs_source_name(), constants.BF2_EXE, gim.game_window.title)
352+
except Exception as e:
353+
logger.error(f'Failed to update OBS capture window: {e}')
348354
elif not got_instance:
349355
logger.error('Game instance was not launched, retrying')
350356
continue

0 commit comments

Comments
 (0)