Controller/RestController.php
public function getAction(Request $request, $documentId)
    {
        $repository = $this->getRequestRepository($request);

        try {
            $document = $this->getCrudService()->read($repository, $documentId);

            if ($document === null) {
                return $this->renderError($request, 'Document does not exist', Response::HTTP_NOT_FOUND);
            }
        } catch (\Exception $e) {
            return $this->renderError($request, $e->getMessage(), Response::HTTP_BAD_REQUEST);
        }

        return $this->renderRest($request, $document, Response::HTTP_OK);
    }
public function getAction(Request $request, $documentId)
    {
        $repository = $this->getRequestRepository($request);

        try {
            $document = $this->getCrudService()->read($repository, $documentId);

            if ($document === null) {
                return $this->renderError($request, 'Document does not exist', Response::HTTP_NOT_FOUND);
            }
        } catch (\Exception $e) {
            return $this->renderError($request, $e->getMessage(), Response::HTTP_BAD_REQUEST);
        }

        return $this->renderRest($request, $document, Response::HTTP_OK);
    }
{@inheritdoc}