An error that occurred while performing a filesystem manipulation via a function in this module. The `paths` field is a sequence of pathnames involved in the operation.
| 127 | |
| 128 | |
| 129 | class FilesystemError(HumanReadableError): |
| 130 | """An error that occurred while performing a filesystem manipulation |
| 131 | via a function in this module. The `paths` field is a sequence of |
| 132 | pathnames involved in the operation. |
| 133 | """ |
| 134 | |
| 135 | def __init__(self, reason, verb, paths, tb=None): |
| 136 | self.paths = paths |
| 137 | super().__init__(reason, verb, tb) |
| 138 | |
| 139 | def get_message(self): |
| 140 | # Use a nicer English phrasing for some specific verbs. |
| 141 | if self.verb in ("move", "copy", "rename"): |
| 142 | clause = ( |
| 143 | f"while {self._gerund()} {displayable_path(self.paths[0])} to" |
| 144 | f" {displayable_path(self.paths[1])}" |
| 145 | ) |
| 146 | elif self.verb in ("delete", "write", "create", "read"): |
| 147 | clause = f"while {self._gerund()} {displayable_path(self.paths[0])}" |
| 148 | else: |
| 149 | clause = ( |
| 150 | f"during {self.verb} of paths" |
| 151 | f" {', '.join(displayable_path(p) for p in self.paths)}" |
| 152 | ) |
| 153 | |
| 154 | return f"{self._reasonstr()} {clause}" |
| 155 | |
| 156 | |
| 157 | class MoveOperation(Enum): |