File: readhelpers.py

package info (click to toggle)
python-clickhouse-driver 0.2.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,516 kB
  • sloc: python: 10,950; pascal: 42; makefile: 31; sh: 3
file content (26 lines) | stat: -rw-r--r-- 717 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from .errors import ServerException
from .reader import read_binary_str, read_binary_uint8, read_binary_int32


def read_exception(buf, additional_message=None):
    code = read_binary_int32(buf)
    name = read_binary_str(buf)
    message = read_binary_str(buf)
    stack_trace = read_binary_str(buf)
    has_nested = bool(read_binary_uint8(buf))

    new_message = ''

    if additional_message:
        new_message += additional_message + '. '

    if name != 'DB::Exception':
        new_message += name + ". "

    new_message += message + ". Stack trace:\n\n" + stack_trace

    nested = None
    if has_nested:
        nested = read_exception(buf)

    return ServerException(new_message, code, nested=nested)