title: Raising a custom message for exception in function
body: <p>MWE of my code distribution:</p>
  
  <pre><code>main.py
  ../func1.py
  </code></pre>
  
  <p>From <code>main.py</code> I call <code>func1.py</code> with:</p>
  
  <pre><code>data_list = [elem1, .., elemN] # Data input.
  params = [1., 2., 5.] # Some parameters.
  
  for elem in data_list:
      try:
          func1(elem, params) # Call function.
      except Exception:
          print traceback.format_exc()
  </code></pre>
  
  <p>This way if the function fails for some element, the main code keeps running executing the remaining elements in the list.</p>
  
  <p>I want to insert a custom error message for a given block of <code>func1</code>, so I've defined:</p>
  
  <pre><code>try:
      # try something
  except ValueError:
      raise ValueError('Custom error message.')
  </code></pre>
  
  <p>When a <code>ValueError</code> occurs in <code>func1</code> the output I get with this, before jumping to the next element in <code>data_list</code>,  is:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/main.py", line 44, in main
      func1(params)
    File "/func1.py", line 68, func1
      raise ValueError('Custom error message.')
  ValueError: Custom error message.
  </code></pre>
  
  <p>Why is the custom error message being printed twice?</p>