- $image = $this->imageRepo->getById($id);
- $page = $image->getPage();
- if ($image === null || $image->type !== 'drawio' || !userCan('page-view', $page)) {
- return $this->jsonError("Image data could not be found");
+ try {
+ $image = $this->imageRepo->getById($id);
+ } catch (Exception $exception) {
+ return $this->jsonError(trans('errors.drawing_data_not_found'), 404);
+ }
+
+ if ($image->type !== 'drawio' || !userCan('page-view', $image->getPage())) {
+ return $this->jsonError(trans('errors.drawing_data_not_found'), 404);