-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a6c721
commit 8cd34d6
Showing
7 changed files
with
49 additions
and
47 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
Sources/Backend/FileManagement/FileVerificationError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// FileVerificationError.swift | ||
// createicns | ||
// | ||
|
||
/// An error that can be thrown during file verification. | ||
enum FileVerificationError: FormattedError { | ||
case alreadyExists(String) | ||
case doesNotExist(String) | ||
case isDirectory(String) | ||
case isNotDirectory(String) | ||
case invalidPathExtension(String, FileType?) | ||
|
||
var errorMessage: FormattedText { | ||
switch self { | ||
case .alreadyExists(let path): | ||
return "'\(path, color: .yellow)' already exists" | ||
case .doesNotExist(let path): | ||
return "No such file or directory '\(path, color: .yellow)'" | ||
case .isDirectory(let path): | ||
return "'\(path, color: .yellow)' is a directory" | ||
case .isNotDirectory(let path): | ||
return "'\(path, color: .yellow)' is not a directory" | ||
case .invalidPathExtension(let pathExtension, let outputType): | ||
let start: FormattedText = "Invalid path extension '\(pathExtension, color: .yellow, style: .bold)'" | ||
guard let outputType else { | ||
return start | ||
} | ||
if let type = outputType.preferredFilenameExtension { | ||
return start + " for expected output type '\(type, color: .cyan, style: .bold)'" | ||
} | ||
return start + " for unknown output type" | ||
} | ||
} | ||
|
||
var fix: FormattedText? { | ||
if case .invalidPathExtension(_, let outputType) = self { | ||
if let type = outputType?.preferredFilenameExtension { | ||
return "Use path extension '\(type, color: .green, style: .bold)'" | ||
} | ||
} | ||
return nil | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...end/ImageProcessing/ProcessingError.swift → ...mageProcessing/ImageProcessingError.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// | ||
// ProcessingError.swift | ||
// ImageProcessingError.swift | ||
// createicns | ||
// | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters