[ClickHouse practice] HTTP error code processing in ClickHouse

When you submit a query through the ClickHouse HTTP interface, any errors are returned in a special field called X-ClickHouse-Exception-Code.

curl -i 'http://localhost:8123?query=select+*+from+wtf'
HTTP/1.1 404 Not Found
Date: Fri, 03 Sep 2021 16:22:40 GMT
Connection: Keep-Alive
Content-Type: text/plain; charset=UTF-8
X-ClickHouse-Server-Display-Name: localhost
Transfer-Encoding: chunked
X-ClickHouse-Exception-Code: 60
Keep-Alive: timeout=3
X-ClickHouse-Summary: {
    
    "read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"}

Code: 60, e.displayText() = DB::Exception: Table default.wtf doesn't exist (version 21.3.1.1)

You can use this query to see all possible ClickHouse error codes:

SELECT concat('\t', name, ' = ', toString(number))
FROM
(
    SELECT
        number,
        errorCodeToName(number) AS name
    FROM system.numbers
    LIMIT 2000
)
WHERE NOT empty(errorCodeToName(number))

Guess you like

Origin blog.csdn.net/weixin_39992480/article/details/128008838