Improved the CreatedRootFolderTask task in the library target to throw error in case the function receives an empty name.

This commit is contained in:
2025-01-12 02:16:30 +01:00
parent db1df0ec62
commit 6bf9c30ad1
3 changed files with 41 additions and 2 deletions
@@ -18,6 +18,10 @@ public struct CreateRootFolderTask {
name: String,
at location: URL? = nil
) async throws -> URL {
guard !name.isEmpty else {
throw CreateRootFolderError.nameIsEmpty
}
let rootFolder = if let location {
location
} else {
@@ -36,3 +40,9 @@ public struct CreateRootFolderTask {
}
}
// MARK: - Errors
public enum CreateRootFolderError: Error {
case nameIsEmpty
}