Throw exception including additional line of information
<p>I have some code where I parse a file. It's simple, like so:</p>

<pre><code>for line in config_file:
    line_split=line.split("|")
    pid_index = int(line_split[3])
    date_locations = [int(i) for i in line_split[2].split(",")]
    in_file = line_split[0]
    out_file = line_split[1]
    file_info.append([in_file, out_file, date_locations, pid_index])
</code></pre>

<p>If something occurs I want Python to proceed printing its usual error messages, but I want to add an additional line at the end of the regular error message, something like:</p>

<pre><code>except:
    print "line \"{0}\"  might have failed to parse".format(line.rstrip())
</code></pre>

<p>However, with the code above only the extra info line is shown - the regular error messages are overwritten!</p>

<p>I have tried adding the following to my catch, but it produces ugly output:</p>

<pre><code>e = sys.exc_info()
for i in e:
    print i
</code></pre>

<p>Is there a simple way to have Python print the regular error messages plus an additional line of info of my choosing?</p>
