private function handleError(Request $request, Response $response)
    {
        $controllerName = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';

        if (!class_exists($controllerName)) {
            return $response;
        }

        $actionName = 'code' . $response->getStatusCode() . 'Action';

        if (!method_exists($controllerName, $actionName)) {
            $actionName = 'defaultAction';
        }

        $controller = new $controllerName($this->drivers, $request, $response);

        return $controller->{$actionName}();
    }