protected function createHttpException($code, $message = null)
    {
        if ($code == 404) {
            $message = 'Entity not found';
        }

        $exception = new HttpException($message, $code);
        return $exception;
    }