summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2009-06-12 15:41:10 +0000
committerrfkelly0 <rfkelly0@67cdc799-7952-0410-af00-57a81ceafa0f>2009-06-12 15:41:10 +0000
commite454f01869c86451b1a54143950c597868a57817 (patch)
treed4eb7733076a8f5e52feee003803a5494ee448d9
parent7a078d59e54948e9b8cd263a9e15dc536758f05f (diff)
downloadpyfilesystem-git-e454f01869c86451b1a54143950c597868a57817.tar.gz
some new error classes, for the future
-rw-r--r--fs/errors.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/fs/errors.py b/fs/errors.py
index e345499..13ceaf2 100644
--- a/fs/errors.py
+++ b/fs/errors.py
@@ -6,7 +6,6 @@
class FSError(Exception):
"""Base exception class for the FS module."""
-
default_message = "Unspecified error"
def __init__(self,msg=None,details=None):
@@ -25,7 +24,6 @@ class FSError(Exception):
class PathError(FSError):
"""Exception for errors to do with a path string."""
-
default_message = "Path is invalid: %(path)s"
def __init__(self,path,**kwds):
@@ -35,7 +33,6 @@ class PathError(FSError):
class OperationFailedError(FSError):
"""Base exception class for errors associated with a specific operation."""
-
default_message = "Unable to %(opname)s: unspecified error [%(errno)s - %(details)s]"
def __init__(self,opname,path=None,**kwds):
@@ -51,14 +48,18 @@ class UnsupportedError(OperationFailedError):
class RemoteConnectionError(OperationFailedError):
- """Exception raised when operation encounter remote connection trouble."""
+ """Exception raised when operations encounter remote connection trouble."""
+ default_message = "Unable to %(opname)s: remote connection errror"
+
+
+class StorageSpaceError(OperationFailedError):
+ """Exception raised when operations encounter storage space trouble."""
default_message = "Unable to %(opname)s: remote connection errror"
class ResourceError(FSError):
"""Base exception class for error associated with a specific resource."""
-
default_message = "Unspecified resource error: %(path)s"
def __init__(self,path,**kwds):
@@ -87,10 +88,20 @@ class FileNotFoundError(ResourceNotFoundError):
class ResourceInvalidError(ResourceError):
- """Exception raised when a required file is not found."""
+ """Exception raised when a resource is the wrong type."""
default_message = "Resource is invalid: %(path)s"
+class NotAFileError(ResourceError):
+ """Exception raised when a required file is not found."""
+ default_message = "That's not a file: %(path)s"
+
+
+class NotADirectoryError(ResourceError):
+ """Exception raised when a required file is not found."""
+ default_message = "That's not a directory: %(path)s"
+
+
class DestinationExistsError(ResourceError):
"""Exception raised when a target destination already exists."""
default_message = "Destination exists: %(path)s"
@@ -109,3 +120,4 @@ class ParentDirectoryMissingError(ResourceError):
class ResourceLockedError(ResourceError):
"""Exception raised when a resource can't be used because it is locked."""
default_message = "Resource is locked: %(path)s"
+