Current File : //proc/self/root/usr/local/lib/python3.6/site-packages/ptrace/__pycache__/error.cpython-36.pyc
3

�dW�@srddlmZddlmZddlmZmZddlmZm	Z	e
Zefdd�Zdd�Z
d	efd
d�ZGdd
�d
e
�ZdS)�)�exc_info)�format_exception)�ERROR�	getLogger)�
getLogFunc�changeLogLevelcCs|t||�}yPt�}t|�}|ddkrXdj|�j�}x|jd�D]}||j��q@WdSWntk
rnYnX|d�dS)zI
    Write a backtrace into the logger with the specified log level.
    rzNone
��
NzUnable to get backtrace)rrr�join�rstrip�split�	Exception)�logger�	log_level�log_func�info�trace�line�r�5/tmp/pip-build-in2aja_b/python-ptrace/ptrace/error.py�writeBacktrace	s
rcCsd|jj|fS)zl
    Format an error as a string. Write the error type as prefix.
    Eg. "[ValueError] invalid value".
    z[%s] %s)�	__class__�__name__)�errorrrr�formatErrorsrrcCsP|s
t�}|jttfkr|�t||�}|d|t|�f�t|t|d�d�dS)ae
    Write an error into the logger:
     - logger: the logger (if None, use getLogger())
     - error: the exception object
     - title: error message prefix (e.g. title="Initialization error")
     - log_level: log level of the error

    If the exception is a SystemExit or a KeyboardInterrupt, re-emit
    (raise) the exception and don't write it.
    z%s: %s�)rN���)rr�
SystemExit�KeyboardInterruptrrrr)rr�titlerrrrr�
writeError#s
r c@seZdZdZddd�ZdS)�PtraceErrorzC
    Ptrace error: have the optional attributes errno and pid.
    NcCstj||�||_||_dS)N)r
�__init__�errno�pid)�self�messager#r$rrrr"<szPtraceError.__init__)NN)r�
__module__�__qualname__�__doc__r"rrrrr!7sr!N)�sysr�	tracebackr�loggingrrZptrace.logging_toolsrrr
Z
PTRACE_ERRORSrrr r!rrrr�<module>s