Skip to content

Commit fa8eef9

Browse files
committed
handle crash
1 parent c1d149b commit fa8eef9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

PiSideCode/camera/camera_info.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ def __init__(
7171
self.calibration_path: str | None = None
7272

7373
def get_supported_resolutions(self):
74-
curr_format = self.controller.get_format()
74+
try:
75+
curr_format = self.controller.get_format()
76+
except FileNotFoundError:
77+
CameraInfo.logger.fatal(f"Camera {self.identifier} disconnected. Cannot read information.")
78+
7579
return self.valid_formats[str(curr_format[0])]
7680

7781
def set_color_format(self, color_format: str) -> bool:
@@ -177,7 +181,10 @@ def get(self, control_name: str):
177181
return self.controller.get_control_value(self.controls[control_name])
178182

179183
def get_format(self) -> None:
180-
curr_format = self.controller.get_format()
184+
try:
185+
curr_format = self.controller.get_format()
186+
except FileNotFoundError:
187+
CameraInfo.logger.fatal(f"Camera {self.identifier} disconnected. Cannot read information.")
181188

182189
self.valid_frame_rates = {
183190
round(1 / float(i)): i

0 commit comments

Comments
 (0)