fix(api): code:nil bei AuthError.serverError-Calls

Anpassung an die neue ManaCore-Signatur
`AuthError.serverError(status:code:message:)` (vorher ohne `code`).
Drei Call-Sites in fetchMedia, deleteMedia und ensureOK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-05-13 19:09:01 +02:00
parent 6805bd78c7
commit 710ede6acd

View file

@ -170,7 +170,7 @@ actor CardsAPI {
func fetchMedia(id: String) async throws -> Data { func fetchMedia(id: String) async throws -> Data {
let (data, http) = try await transport.request(path: "/api/v1/media/\(id)") let (data, http) = try await transport.request(path: "/api/v1/media/\(id)")
guard (200 ..< 300).contains(http.statusCode) else { guard (200 ..< 300).contains(http.statusCode) else {
throw AuthError.serverError(status: http.statusCode, message: "media fetch failed") throw AuthError.serverError(status: http.statusCode, code: nil, message: "media fetch failed")
} }
return data return data
} }
@ -178,7 +178,7 @@ actor CardsAPI {
/// `DELETE /api/v1/media/:id` Soft-Forget. (Endpoint heute nicht /// `DELETE /api/v1/media/:id` Soft-Forget. (Endpoint heute nicht
/// implementiert serverseitig; Stub bleibt für späteren Use.) /// implementiert serverseitig; Stub bleibt für späteren Use.)
func deleteMedia(id _: String) async throws { func deleteMedia(id _: String) async throws {
throw AuthError.serverError(status: 501, message: "media delete not implemented on server") throw AuthError.serverError(status: 501, code: nil, message: "media delete not implemented on server")
} }
// MARK: - Deck-Mutations // MARK: - Deck-Mutations
@ -326,7 +326,7 @@ actor CardsAPI {
private func ensureOK(_ http: HTTPURLResponse, data: Data) throws { private func ensureOK(_ http: HTTPURLResponse, data: Data) throws {
guard (200 ..< 300).contains(http.statusCode) else { guard (200 ..< 300).contains(http.statusCode) else {
let message = (try? JSONDecoder().decode(CardsServerError.self, from: data))?.error let message = (try? JSONDecoder().decode(CardsServerError.self, from: data))?.error
throw AuthError.serverError(status: http.statusCode, message: message) throw AuthError.serverError(status: http.statusCode, code: nil, message: message)
} }
} }
} }