Did I find the right examples for you? yes no

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)
Extracts the actual exception and relevant code that triggered it from the message from differ.

        def parse_error_string(message):
    """
    Extracts the actual exception and relevant code that triggered it from the message from differ.
    """
    # split message into array of lines for processing
    lines = message.split('\n')

    # the message will have some crap, then a traceback, then the exception then more crap.
    # we want to parse out the most relevant file/method in the traceback and the exception.
    # the traceback is over when you see a non-indented line that doesn't start with File, 
    # so grab that at the exception. the most relevant line of the traceback is the lowest
    # one that is in /var/www or just the lowest one if there are none that match that.

    # stays none until we've seen the first line after the traceback section
    exception = None

    # stays none until we've seen the first line of the traceback section, preferences:
    # 1) product_location /var/www (except example)
    # 2) shared_location  /var/www/example
    # 3) other_location   anything else, usually /usr*
    product_location = None
    shared_location = None
    other_location = None

    for line in lines:
        if file_line.match(line):
            if lol_file_line.match(line):
                if shared_file_line.match(line):
                    shared_location = line
                else:
                    product_location = line
            else:
                other_location = line
        elif (product_location or shared_location or other_location) \
             and not indented_line.match(line):
            exception = line
            # got the exception, we're done here
            break

    if product_location:
        location = product_location
    elif shared_location:
        location = shared_location
    else:
        location = other_location

    # parse the location line. it looks like:
    # File '/var/www/example/fileserver/client.py', line 50 in _connect
    filename = None
    line_number = None
    method = None
    if location:
        words = location.split()
        filename = words[1].strip('\'",')
        line_number = words[3].strip(',')
        try:
            method = words[5]
        except:
            method = "NO_METHOD_LISTED"

    # extract the exception type from exception. it looks like:
    # TypeError: unsupported operand type(s) for -=: 'int' and 'str'
    if exception:
        exception = exception.split(':')[0]

    return filename, line_number, method, exception
        


src/l/o/lol-logwatcher-HEAD/differ.py   lol-logwatcher(Download)
def process_completed_error(local_err_msg, lolfly_error, debug, db_inject):
    # parse out the error some more and gather data
    location, line_number, method, exception = util.parse_error_string(local_err_msg)
 
    # set the info inside our lolfly dictionary