I need to use my own custom error enum in tasks that I create:
enum MyError: Error {
case someError
}
var myTask: Task<MyModel, MyError> = Task { () throws -> MyModel in
// in case of an error:
// throw .someError
// ... perform some work
return MyModel()
}
but I got the following error at the beginning of Task initializer:
Referencing initializer 'init(priority:operation:)' on 'Task' requires the types 'MyError' and 'Error' be equivalent
.
How can I restrict the Task
to only throw errors that are of my custom error type MyError
?