public function dispatch($uri, $method = 'GET', $arguments = [])
    {
        $this->originalUri = $uri;
        $this->uri = $this->prepareUri($uri);

        $methods = [
            'GET',
            'HEAD',
            'POST',
            'PUT',
            'DELETE',
            'TRACE',
            'OPTIONS',
            'CONNECT',
            'PATCH',
        ];
        $method = strtoupper($method);
        $this->method = in_array($method, $methods) ? $method : 'GET';

        try {
            // Get the response
            $response = $this->getResponse();

            if (!$this->raw) {
                $response = $this->createTemplateResponse($response);
            }

            // Output the response
            echo $response;

            return $response;
        } catch (\Exception $exception) {
            $fileHandle = fopen('php://stderr', 'w');
            fwrite($fileHandle, (string)$exception);
            if (ConfigurationManager::getConfiguration()->isDevelopmentMode()) {
                echo new Response('An error occurred: ' . $exception, 500);
            } else {
                echo new Response('An error occurred', 500);
            }
        }

        return '';
    }