Refactor DefaultVeranstalterRepository to use exception classes instead of objects. Clean up unused imports in VeranstalterModule and VeranstalterAuswahlV2.
Some checks failed
Desktop CI — Headless Tests & Build / Compose Desktop — Tests (headless) & Build (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Has been cancelled
Some checks failed
Desktop CI — Headless Tests & Build / Compose Desktop — Tests (headless) & Build (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, api-gateway, api-gateway) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Has been cancelled
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Has been cancelled
This commit is contained in:
parent
f82dbd64a5
commit
2c8d16b27f
|
|
@ -19,9 +19,9 @@ class DefaultVeranstalterRepository(
|
|||
val response = client.get(ApiRoutes.Veranstalter.ROOT)
|
||||
when {
|
||||
response.status.isSuccess() -> response.body<List<VeranstalterDto>>().map { it.toDomain() }
|
||||
response.status == HttpStatusCode.Unauthorized -> throw AuthExpired
|
||||
response.status == HttpStatusCode.Forbidden -> throw AuthForbidden
|
||||
response.status.value >= 500 -> throw ServerError
|
||||
response.status == HttpStatusCode.Unauthorized -> throw AuthExpired()
|
||||
response.status == HttpStatusCode.Forbidden -> throw AuthForbidden()
|
||||
response.status.value >= 500 -> throw ServerError()
|
||||
else -> throw HttpError(response.status.value)
|
||||
}
|
||||
}
|
||||
|
|
@ -30,10 +30,10 @@ class DefaultVeranstalterRepository(
|
|||
val response = client.get("${ApiRoutes.Veranstalter.ROOT}/$id")
|
||||
when {
|
||||
response.status.isSuccess() -> response.body<VeranstalterDto>().toDomain()
|
||||
response.status == HttpStatusCode.NotFound -> throw NotFound
|
||||
response.status == HttpStatusCode.Unauthorized -> throw AuthExpired
|
||||
response.status == HttpStatusCode.Forbidden -> throw AuthForbidden
|
||||
response.status.value >= 500 -> throw ServerError
|
||||
response.status == HttpStatusCode.NotFound -> throw NotFound()
|
||||
response.status == HttpStatusCode.Unauthorized -> throw AuthExpired()
|
||||
response.status == HttpStatusCode.Forbidden -> throw AuthForbidden()
|
||||
response.status.value >= 500 -> throw ServerError()
|
||||
else -> throw HttpError(response.status.value)
|
||||
}
|
||||
}
|
||||
|
|
@ -42,8 +42,8 @@ class DefaultVeranstalterRepository(
|
|||
val response = client.post(ApiRoutes.Veranstalter.ROOT) { setBody(model.toDto()) }
|
||||
when {
|
||||
response.status.isSuccess() -> response.body<VeranstalterDto>().toDomain()
|
||||
response.status == HttpStatusCode.Conflict -> throw Conflict
|
||||
response.status.value >= 500 -> throw ServerError
|
||||
response.status == HttpStatusCode.Conflict -> throw Conflict()
|
||||
response.status.value >= 500 -> throw ServerError()
|
||||
else -> throw HttpError(response.status.value)
|
||||
}
|
||||
}
|
||||
|
|
@ -52,9 +52,9 @@ class DefaultVeranstalterRepository(
|
|||
val response = client.put("${ApiRoutes.Veranstalter.ROOT}/$id") { setBody(model.toDto()) }
|
||||
when {
|
||||
response.status.isSuccess() -> response.body<VeranstalterDto>().toDomain()
|
||||
response.status == HttpStatusCode.NotFound -> throw NotFound
|
||||
response.status == HttpStatusCode.Conflict -> throw Conflict
|
||||
response.status.value >= 500 -> throw ServerError
|
||||
response.status == HttpStatusCode.NotFound -> throw NotFound()
|
||||
response.status == HttpStatusCode.Conflict -> throw Conflict()
|
||||
response.status.value >= 500 -> throw ServerError()
|
||||
else -> throw HttpError(response.status.value)
|
||||
}
|
||||
}
|
||||
|
|
@ -63,17 +63,17 @@ class DefaultVeranstalterRepository(
|
|||
val response = client.delete("${ApiRoutes.Veranstalter.ROOT}/$id")
|
||||
when {
|
||||
response.status.isSuccess() -> Unit
|
||||
response.status == HttpStatusCode.NotFound -> throw NotFound
|
||||
response.status.value >= 500 -> throw ServerError
|
||||
response.status == HttpStatusCode.NotFound -> throw NotFound()
|
||||
response.status.value >= 500 -> throw ServerError()
|
||||
else -> throw HttpError(response.status.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fehler-Typen (vereinfachtes DomainError-Äquivalent)
|
||||
object AuthExpired : RuntimeException("AUTH_EXPIRED")
|
||||
object AuthForbidden : RuntimeException("AUTH_FORBIDDEN")
|
||||
object NotFound : RuntimeException("NOT_FOUND")
|
||||
object Conflict : RuntimeException("CONFLICT")
|
||||
object ServerError : RuntimeException("SERVER_ERROR")
|
||||
class AuthExpired : RuntimeException("AUTH_EXPIRED")
|
||||
class AuthForbidden : RuntimeException("AUTH_FORBIDDEN")
|
||||
class NotFound : RuntimeException("NOT_FOUND")
|
||||
class Conflict : RuntimeException("CONFLICT")
|
||||
class ServerError : RuntimeException("SERVER_ERROR")
|
||||
class HttpError(val code: Int) : RuntimeException("HTTP_$code")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package at.mocode.frontend.features.veranstalter.di
|
|||
|
||||
import at.mocode.frontend.features.veranstalter.data.remote.DefaultVeranstalterRepository
|
||||
import at.mocode.frontend.features.veranstalter.domain.VeranstalterRepository
|
||||
import io.ktor.client.HttpClient
|
||||
import org.koin.core.qualifier.named
|
||||
import org.koin.dsl.module
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import androidx.compose.foundation.lazy.items
|
|||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.ArrowForward
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user