getElement->execute( new GetElementRequest(id: $id) ); } catch (BadRequestException $exception) { return new JsonResponse([ 'error' => $exception->getMessage(), ], 400); } catch (NotFoundException $exception) { return new JsonResponse([ 'error' => $exception->getMessage(), ], 404); } return new JsonResponse([ 'element' => [ 'id' => $element->getId(), 'title' => $element->getTitle(), ], ], 200); } }