private function defaultHandler(ServerRequestInterface $request, ResponseInterface $response)
    {
        $statusCode = $response->getStatusCode();
        $exception = self::getException($request);
        $message = $exception ? $exception->getMessage() : '';

        switch (Utils\Helpers::getMimeType($response)) {
            case 'text/plain':
            case 'text/css':
            case 'text/javascript':
                return self::errorText($statusCode, $message);

            case 'image/jpeg':
                return self::errorImage($statusCode, $message, 'imagejpeg');

            case 'image/gif':
                return self::errorImage($statusCode, $message, 'imagegif');

            case 'image/png':
                return self::errorImage($statusCode, $message, 'imagepng');

            case 'image/svg+xml':
                return self::errorSvg($statusCode, $message);

            case 'application/json':
                return self::errorJson($statusCode, $message);

            case 'text/xml':
                return self::errorXml($statusCode, $message);

            default:
                return self::errorHtml($statusCode, $message);
        }
    }