protected function validateSession($session) { try { if (is_null($this->shareToken)) { new File($session->getFileId()); } else { File::getByShareToken($this->shareToken); } } catch (\Exception $e) { $this->logger->warning('Error. Session no longer exists. ' . $e->getMessage(), ['app' => $this->appName]); $ex = new BadRequestException(); $ex->setBody(implode(',', $this->request->getParams())); throw $ex; } }