title: How to handle OSError: [Errno 36] File name too long
body: <p>When handling the errors that occur when trying to create an existing file or trying to use a file that doesn't exist the <code>OSError</code>s that get thrown have a subclass (<code>FileExistsError</code>, <code>FileNotFoundError</code>). I couldn't find that subclass for the special case when the filename is too long.</p>
  
  <p>The exact error message is:</p>
  
  <pre><code>OSError: [Errno 36] File name too long: 'filename'
  </code></pre>
  
  <p>I would like to catch the OSError that occurs when the filename is too long, but <em>only when</em> the filename is too long. I do <em>not</em> want to catch other <code>OSError</code>s that might occur. Is there a way to achieve this?</p>
  
  <p><strong>Edit:</strong> I know that I could check the filename against a length but the maximum filename length varies too much depending on the OS and the filesystem and I don't see a "clean" solution that way.</p>