@classmethod
def get_error(cls, pg_error):
    """Get error instance by psycopg2.Error

        :param pg_error: psycopg2.Error instance
        :return: PgClientError instance
        """
    error_cls = cls.get_error_class(pg_error.pgcode)
    return error_cls(message=getattr(pg_error, 'message', pg_error.pgerror),
        pgcode=pg_error.pgcode, pgerror=pg_error.pgerror, diag=pg_error.diag)
