In Python 3, how can we catch a specific OSError
exception?
My current code catches all OSError
, but only OSError: [Errno 12]
needs to be caught.
try: foo()except OSError as e: print('Caught OSError: [Errno12]')
The full error message is:
Caught OSError: [Errno12] Cannot allocate memory
How can we let Python catch only the Errno12
variant of OSError
?