all Python 3Exceptionsexception
shutil.Error
module exceptions
The base error of shutil operations (e.g. copytree collecting several errors).
Syntax
raise shutil.Error
This is about multi-file operations: copytree does not stop at the first failure but copies what it can and finally raises a single Error whose args[0] is a list of (source, destination, reason) tuples. So inspect that list instead of a single message, otherwise you silently lose some of the failures. The class derives from OSError, so a broad except OSError will catch it as well.
Examples
import shutil
try:
raise shutil.Error
except shutil.Error as e:
print(type(e).__name__) # → Error
See also
Open in the full glossarydocs.python.orgReport an inaccuracy