protected HttpException determineHttpException()

in server/src/main/java/org/apache/cassandra/sidecar/handlers/AbstractHandler.java [198:231]


    protected HttpException determineHttpException(Throwable cause)
    {
        if (cause instanceof HttpException)
        {
            return (HttpException) cause;
        }

        if (cause instanceof JmxAuthenticationException)
        {
            return wrapHttpException(HttpResponseStatus.SERVICE_UNAVAILABLE, cause);
        }

        if (cause instanceof OperationUnavailableException)
        {
            return wrapHttpException(HttpResponseStatus.SERVICE_UNAVAILABLE, cause.getMessage(), cause);
        }

        if (cause instanceof NoSuchCassandraInstanceException)
        {
            return wrapHttpException(HttpResponseStatus.MISDIRECTED_REQUEST, cause.getMessage(), cause);
        }

        if (cause instanceof IllegalArgumentException)
        {
            return wrapHttpException(HttpResponseStatus.BAD_REQUEST, cause.getMessage(), cause);
        }

        if (cause instanceof IllegalStateException)
        {
            return wrapHttpException(HttpResponseStatus.INTERNAL_SERVER_ERROR, cause.getMessage(), cause);
        }

        return wrapHttpException(HttpResponseStatus.INTERNAL_SERVER_ERROR, cause);
    }