| 33 | |
| 34 | impl fmt::Display for ResPathError { |
| 35 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 36 | let message = match self { |
| 37 | Self::Empty => "resource path is empty", |
| 38 | Self::MissingScheme => "resource path must start with res://, dlc://, or user://", |
| 39 | Self::UnknownScheme => "resource path scheme must be res, dlc, or user", |
| 40 | Self::EmptyPath => "resource path body is empty", |
| 41 | Self::EmptyDlcName => "dlc resource path needs a dlc name or self", |
| 42 | Self::InvalidDlcName => "dlc resource path name has invalid characters", |
| 43 | Self::InvalidSeparator => "resource path must use / separators", |
| 44 | Self::Traversal => "resource path cannot contain . or .. path segments", |
| 45 | Self::ControlCharacter => "resource path cannot contain control characters", |
| 46 | }; |
| 47 | f.write_str(message) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | impl std::error::Error for ResPathError {} |