Edit File: error.cpython-36.pyc
3 �eW � @ sr d dl mZ d dlmZ d dlmZmZ d dlmZm Z e Zefdd�Zdd� Z d efd d�ZG dd � d e �ZdS )� )�exc_info)�format_exception)�ERROR� getLogger)� getLogFunc�changeLogLevelc C s| t | |�}yPt� }t|� }|d dkrXdj|�j� }x|jd�D ]}||j� � q@W dS W n tk rn Y nX |d� dS )zI Write a backtrace into the logger with the specified log level. r zNone � � NzUnable to get backtrace)r r r �join�rstrip�split� Exception)�logger� log_level�log_func�info�trace�line� r �5/tmp/pip-build-uv1wutoy/python-ptrace/ptrace/error.py�writeBacktrace s r c C s d| j j| f S )zl Format an error as a string. Write the error type as prefix. Eg. "[ValueError] invalid value". z[%s] %s)� __class__�__name__)�errorr r r �formatError s r r c C sP | 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� )r N���)r r � SystemExit�KeyboardInterruptr r r r )r r �titler r r r r � writeError# s r c @ s e Zd ZdZddd�ZdS )�PtraceErrorzC Ptrace error: have the optional attributes errno and pid. Nc C s t j| |� || _|| _d S )N)r �__init__�errno�pid)�self�messager# r$ r r r r"