Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions Bitkit/Utilities/Errors.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import LDKNode

enum CustomServiceError: Error {
enum CustomServiceError: LocalizedError {
case nodeNotSetup
case nodeNotStarted
case onchainWalletNotInitialized
Expand All @@ -12,14 +12,54 @@ enum CustomServiceError: Error {
case regtestOnlyMethod
case channelSizeExceedsMaximum
case currencyRateUnavailable

var errorDescription: String? {
switch self {
case .nodeNotSetup:
return "Node is not setup"
case .nodeNotStarted:
return "Node is not started"
case .onchainWalletNotInitialized:
return "Onchain wallet not created"
case .mnemonicNotFound:
return "Mnemonic not found"
case .nodeStillRunning:
return "Node is still running"
case .onchainWalletStillRunning:
return "Onchain wallet is still running"
case .invalidNodeSigningMessage:
return "Invalid node signing message"
case .regtestOnlyMethod:
return "Method only available in regtest environment"
case .channelSizeExceedsMaximum:
return "Channel size exceeds maximum allowed size"
case .currencyRateUnavailable:
return "Currency rate unavailable"
}
}
}

enum KeychainError: Error {
enum KeychainError: LocalizedError {
case failedToSave
case failedToSaveAlreadyExists
case failedToDelete
case failedToLoad
case keychainWipeNotAllowed

var errorDescription: String? {
switch self {
case .failedToSave:
return "Failed to save to keychain"
case .failedToSaveAlreadyExists:
return "Failed to save to keychain: item already exists"
case .failedToDelete:
return "Failed to delete from keychain"
case .failedToLoad:
return "Failed to load from keychain"
case .keychainWipeNotAllowed:
return "Keychain wipe not allowed"
}
}
}

enum BlocktankError_deprecated: Error {
Expand Down
3 changes: 3 additions & 0 deletions Bitkit/ViewModels/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ extension AppViewModel {
}

func toast(_ error: Error) {
if error is CancellationError {
return
}
toast(type: .error, title: "Error", description: error.localizedDescription)
}

Expand Down
Loading