:library:core:network
Purpose
Supplies the shared Ktor HTTP client and the translation of its failures into NetworkException.
Owns
Ktor client construction and JSON/content-negotiation configuration (
KtorClient).Translating the client's failures into
NetworkException(from:library:core:common):networkCall { },Throwable.toNetworkException()andHttpStatusCode.toNetworkException().
Does not own
Feature endpoints, DTOs, mappers, or repositories; those remain in the feature modules.
The text a screen shows for a failure, mapped by
core.ui.screen.toUiTextin:library:core:ui.NetworkExceptionitself, which:library:core:commonowns so a repository can throw it without depending on Ktor.
Depends on
:library:core:commonforNetworkException.
Used by
:library:apptoolkitfor DI composition.Every feature with a remote source:
:library:feature:changelog,:library:feature:faq,:library:feature:issuereporter, and the sample's apps catalogue.
Flow chart
flowchart TD
Repository[Feature repository] -->|networkCall| Remote[Feature-owned remote data source]
Remote --> Client[Shared Ktor HttpClient]
Client --> Endpoint[Feature endpoint]
Endpoint -->|decoded response| Remote
Endpoint -->|HTTP status| Status[HttpStatusCode.toNetworkException]
Client -->|transport failure| Throwable[Throwable.toNetworkException]
Status --> Exception[NetworkException with a reason]
Throwable --> Exception
Remote -->|data| Repository
Exception --> RepositoryArchitectural decisions
A repository returns its data or throws. Remote calls run in
networkCall { }, so a failure reaches the caller as aNetworkExceptionwhosereasonsays what went wrong and whosecauseis the client's exception. Cancellation passes through untouched.Ktor suspends, so neither the client nor
networkCallswitches dispatchers; a repository that only calls the network needs noDispatcherProvider.Client construction and the failure vocabulary are shared; URLs, DTOs, decoding choices, and fallback policy stay with each feature's remote source and repository.
This module has no resources: failure text belongs to the UI layer.
Public contracts
KtorClient,networkCall,Throwable.toNetworkException()andHttpStatusCode.toNetworkException().
Internal implementations
Ktor engine and logging configuration.