title: Customizing a FileNotFoundError message in Python
body: <p>I'm able to capture an exception to change its message. For example:</p>
  
  <pre class="lang-py prettyprint-override"><code>def parse(val, parse_function, errmsg):
      try:
          return parse_function(val)
      except ValueError as e:
          e.args = (errmsg,) #Overwrites the exception message
          raise e
  
  val = input("Enter a number: ")
  try:
      val = parse(val, float, "The input is not a number")
  except ValueError as e:
      print(e) #if executed, prints "The input is not a number"
  </code></pre>
  
  <p>But, if I do it with a FileNotFoundException, it doesn't work:</p>
  
  <pre class="lang-py prettyprint-override"><code>def do_stuff(filename):
      try:
          with open(filename, "r") as file:
              pass
              #do stuff with the file
      except FileNotFoundError as e:
          e.args = ("The file doesn't exist",) #Overwrites the exception message
          raise e
  
  try:
      do_stuff("inexistent_file_name")
  except FileNotFoundError as e:
      print(e) #Doesn't print "The file doesn't exist", prints "[Errno 2] No such file or directory: 'inexistent_file_name'"
  </code></pre>
  
  <p>Why is this? And how can I customize a FileNotFoundException message?</p>