Invalid conversion from throwing function of type '@Sendable () async throws -> Void' to non-throwing function type '@Sendable () async -> Void’
async throws를 사용한 함수를 .task() 안에 사용하려고 했다.
처음에는 .task()
안에 do-try-catch문을 사용하면 안되는건가 싶어서 .task()
대신에 .onAppear()
안에 넣어 봤다.
Invalid conversion from 'async' function of type '() async throws -> Void' to synchronous function type '() -> Void’
응 안 되는거 똑같아 ㅋ 당연하지 onAppear
만으로는 우선 await
를 사용하지 못하니까
.
.
.
함수에서 do-try-catch
, throw
관련된 코드를 계속 수정해봤지만 에러는 그대로...
그러다 이 스택오버플로우를 발견했다.
https://stackoverflow.com/questions/75225934/task-works-but-task-throws-invalid-conversion-from-throwing-function-of-typ
.onAppear(Task())
를 사용해라.
.task()
안에서 catch
문의 throw(error)
를 하지 말자.