mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-27 23:36:21 +02:00
Moves the exceptions to our own signing exceptions
This commit is contained in:
@@ -38,11 +38,10 @@ class NostrSignerInternal(
|
||||
inline fun <T> runWrapErrors(action: () -> T): T =
|
||||
try {
|
||||
action()
|
||||
} catch (e: SignerExceptions) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
throw SignerExceptions.CouldNotPerformException("Could not sign event.", e)
|
||||
if (e is SignerExceptions) throw e
|
||||
throw SignerExceptions.CouldNotPerformException("Could not perform the operation", e)
|
||||
}
|
||||
|
||||
override suspend fun <T : Event> sign(
|
||||
|
@@ -62,7 +62,7 @@ abstract class DecryptCache<I : Any, T : Any>(
|
||||
// User has did not reply to the approval request. Ignore until later time.
|
||||
cache = CacheResults.CanTryAgain<T>(TimeUtils.tenSecondsFromNow())
|
||||
} catch (e: SignerExceptions.CouldNotPerformException) {
|
||||
Log.w("DecryptCache", "CouldNotPerformException", e)
|
||||
// Log.w("DecryptCache", "CouldNotPerformException", e)
|
||||
// Decryption failed. This key might not be able to decrypt anything. Don't try again.
|
||||
cache = CacheResults.DontTryAgain<T>()
|
||||
} catch (e: SignerExceptions.SignerNotFoundException) {
|
||||
|
@@ -101,7 +101,7 @@ class PrivateZapRequestBuilder {
|
||||
event.createdAt,
|
||||
)
|
||||
} else {
|
||||
throw IllegalArgumentException("Couldn't find a secret to use. The private zap is neither a post nor an author zap")
|
||||
throw SignerExceptions.CouldNotPerformException("Couldn't find a secret to use. The private zap is neither a post nor an author zap")
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -112,13 +112,13 @@ class PrivateZapRequestBuilder {
|
||||
// the sender is logged in.
|
||||
decryptAnonTag(event.getAnonTag(), myPrivateKeyForThisEvent, altPubkeyToUse)
|
||||
} else {
|
||||
throw IllegalArgumentException("This private zap cannot be decrypted by this key.")
|
||||
throw SignerExceptions.CouldNotPerformException("This private zap cannot be decrypted by this key.")
|
||||
}
|
||||
} else {
|
||||
throw IllegalArgumentException("Recipient pubkey not found.")
|
||||
throw SignerExceptions.CouldNotPerformException("Recipient pubkey not found.")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
throw IllegalArgumentException("Failed to create pubkey for ZapRequest ${event.id}. ${e.message}")
|
||||
throw SignerExceptions.CouldNotPerformException("Failed to create pubkey for ZapRequest ${event.id}. ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user