Skip to content

Commit 7ec7678

Browse files
committed
fix: Handle OSError when saving screenshot to disk
1 parent d116179 commit 7ec7678

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

BF2AutoSpectator/common/utility.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,15 @@ def screenshot_region(
274274
config = Config()
275275
if config.debug_screenshot():
276276
# Save screenshot
277-
cropped.save(
278-
os.path.join(
279-
Config.DEBUG_DIR,
280-
f'screenshot-{datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")}.jpg'
277+
try:
278+
cropped.save(
279+
os.path.join(
280+
Config.DEBUG_DIR,
281+
f'screenshot-{datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f")}.jpg'
282+
)
281283
)
282-
)
284+
except OSError as e:
285+
logger.error(f'Failed to save screenshot to disk: {e}')
283286

284287
results.append(cropped)
285288

0 commit comments

Comments
 (0)