Skip to content

Commit b684ca2

Browse files
committed
refactor: use class for all errors to fix warnings
1 parent 58c15de commit b684ca2

17 files changed

Lines changed: 85 additions & 99 deletions

app/src/main/java/to/bitkit/data/ChatwootHttpClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ class ChatwootHttpClient @Inject constructor(
6060
}
6161

6262
sealed class ChatwootHttpError(message: String) : AppError(message) {
63-
data class InvalidResponse(override val message: String) : ChatwootHttpError(message)
63+
class InvalidResponse(override val message: String) : ChatwootHttpError(message)
6464
}

app/src/main/java/to/bitkit/data/backup/VssBackupClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class VssBackupClient @Inject constructor(
4040
Logger.verbose("Building VSS client with lnurlAuthServerUrl: '$lnurlAuthServerUrl'")
4141
if (lnurlAuthServerUrl.isNotEmpty()) {
4242
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name)
43-
?: throw ServiceError.MnemonicNotFound
43+
?: throw ServiceError.MnemonicNotFound()
4444
val passphrase = keychain.loadString(Keychain.Key.BIP39_PASSPHRASE.name)
4545

4646
vssNewClientWithLnurlAuth(

app/src/main/java/to/bitkit/data/backup/VssStoreIdProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class VssStoreIdProvider @Inject constructor(
1919
synchronized(this) {
2020
cacheMap[walletIndex]?.let { return it }
2121

22-
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name) ?: throw ServiceError.MnemonicNotFound
22+
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name)
23+
?: throw ServiceError.MnemonicNotFound()
2324
val passphrase = keychain.loadString(Keychain.Key.BIP39_PASSPHRASE.name)
2425

2526
val storeId = vssDeriveStoreId(

app/src/main/java/to/bitkit/data/widgets/BlocksService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ class BlocksService @Inject constructor(
101101
* Block-specific error types
102102
*/
103103
sealed class BlockError(message: String) : AppError(message) {
104-
data class InvalidResponse(override val message: String) : BlockError(message)
104+
class InvalidResponse(override val message: String) : BlockError(message)
105105
}

app/src/main/java/to/bitkit/data/widgets/NewsService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ class NewsService @Inject constructor(
5252
* News-specific error types
5353
*/
5454
sealed class NewsError(message: String) : AppError(message) {
55-
data class InvalidResponse(override val message: String) : NewsError(message)
55+
class InvalidResponse(override val message: String) : NewsError(message)
5656
}

app/src/main/java/to/bitkit/data/widgets/PriceService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,6 @@ class PriceService @Inject constructor(
180180
* Price-specific error types
181181
*/
182182
sealed class PriceError(message: String) : AppError(message) {
183-
data class InvalidResponse(override val message: String) : PriceError(message)
184-
data class NetworkError(override val message: String) : PriceError(message)
183+
class InvalidResponse(override val message: String) : PriceError(message)
184+
class NetworkError(override val message: String) : PriceError(message)
185185
}

app/src/main/java/to/bitkit/repositories/BlocktankRepo.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ class BlocktankRepo @Inject constructor(
201201
description: String = Env.DEFAULT_INVOICE_MESSAGE,
202202
): Result<IcJitEntry> = withContext(bgDispatcher) {
203203
try {
204-
if (coreService.isGeoBlocked()) throw ServiceError.GeoBlocked
205-
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted
204+
if (coreService.isGeoBlocked()) throw ServiceError.GeoBlocked()
205+
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted()
206206
val lspBalance = getDefaultLspBalance(clientBalance = amountSats)
207207
val channelSizeSat = amountSats + lspBalance
208208

@@ -230,7 +230,7 @@ class BlocktankRepo @Inject constructor(
230230
channelExpiryWeeks: UInt = DEFAULT_CHANNEL_EXPIRY_WEEKS,
231231
): Result<IBtOrder> = withContext(bgDispatcher) {
232232
try {
233-
if (coreService.isGeoBlocked()) throw ServiceError.GeoBlocked
233+
if (coreService.isGeoBlocked()) throw ServiceError.GeoBlocked()
234234

235235
val options = defaultCreateOrderOptions(clientBalanceSat = spendingBalanceSats)
236236

@@ -323,7 +323,7 @@ class BlocktankRepo @Inject constructor(
323323
}
324324

325325
private suspend fun defaultCreateOrderOptions(clientBalanceSat: ULong): CreateOrderOptions {
326-
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted
326+
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted()
327327
val timestamp = nowTimestamp().toString()
328328
val signature = lightningService.sign("channelOpen-$timestamp")
329329

@@ -350,7 +350,7 @@ class BlocktankRepo @Inject constructor(
350350
}
351351

352352
val satsPerEur = getSatsPerEur()
353-
?: throw ServiceError.CurrencyRateUnavailable
353+
?: throw ServiceError.CurrencyRateUnavailable()
354354

355355
val params = DefaultLspBalanceParams(
356356
clientBalanceSat = clientBalance,
@@ -363,10 +363,10 @@ class BlocktankRepo @Inject constructor(
363363

364364
fun calculateLiquidityOptions(clientBalanceSat: ULong): Result<ChannelLiquidityOptions> {
365365
val blocktankInfo = blocktankState.value.info
366-
?: return Result.failure(ServiceError.BlocktankInfoUnavailable)
366+
?: return Result.failure(ServiceError.BlocktankInfoUnavailable())
367367

368368
val satsPerEur = getSatsPerEur()
369-
?: return Result.failure(ServiceError.CurrencyRateUnavailable)
369+
?: return Result.failure(ServiceError.CurrencyRateUnavailable())
370370

371371
val existingChannelsTotalSat = totalBtChannelsValueSats(blocktankInfo)
372372

@@ -466,7 +466,7 @@ class BlocktankRepo @Inject constructor(
466466
}
467467

468468
private suspend fun claimGiftCodeWithoutLiquidity(code: String, amount: ULong): GiftClaimResult {
469-
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted
469+
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted()
470470

471471
val order = ServiceQueue.CORE.background {
472472
giftOrder(clientNodeId = nodeId, code = "blocktank-gift-code:$code")

app/src/main/java/to/bitkit/repositories/LightningRepo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ class LightningRepo @Inject constructor(
628628
callback: String,
629629
domain: String,
630630
): Result<String> = runCatching {
631-
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name) ?: throw ServiceError.MnemonicNotFound
631+
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name) ?: throw ServiceError.MnemonicNotFound()
632632
val passphrase = keychain.loadString(Keychain.Key.BIP39_PASSPHRASE.name)
633633

634634
val result = lnurlAuth(

app/src/main/java/to/bitkit/repositories/WalletRepo.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ class WalletRepo @Inject constructor(
347347
count: Int = 20,
348348
): Result<List<AddressModel>> = withContext(bgDispatcher) {
349349
return@withContext try {
350-
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name) ?: throw ServiceError.MnemonicNotFound
350+
val mnemonic = keychain.loadString(Keychain.Key.BIP39_MNEMONIC.name)
351+
?: throw ServiceError.MnemonicNotFound()
351352

352353
val passphrase = keychain.loadString(Keychain.Key.BIP39_PASSPHRASE.name)
353354

app/src/main/java/to/bitkit/services/AppUpdaterService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ class AppUpdaterService @Inject constructor(
3737
}
3838

3939
sealed class AppUpdaterError(message: String) : AppError(message) {
40-
data class InvalidResponse(override val message: String) : AppUpdaterError(message)
40+
class InvalidResponse(override val message: String) : AppUpdaterError(message)
4141
}

0 commit comments

Comments
 (0)