mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-02 13:43:06 +00:00
Raise SignerError instead of propagating AsyncLockError (#109)
This commit is contained in:
parent
d2b11a8657
commit
b505ef1ab8
@ -133,7 +133,7 @@ proc send(
|
||||
function: string,
|
||||
parameters: tuple,
|
||||
overrides = TransactionOverrides()
|
||||
): Future[?TransactionResponse] {.async: (raises: [AsyncLockError, SignerError, ProviderError, CancelledError]).} =
|
||||
): Future[?TransactionResponse] {.async: (raises: [SignerError, ProviderError, CancelledError]).} =
|
||||
|
||||
if signer =? contract.signer:
|
||||
withLock(signer):
|
||||
@ -279,7 +279,6 @@ func addAsyncPragma(procedure: var NimNode) =
|
||||
newIdentNode("CancelledError"),
|
||||
newIdentNode("ProviderError"),
|
||||
newIdentNode("EthersError"),
|
||||
newIdentNode("AsyncLockError"),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
@ -12,7 +12,7 @@ type
|
||||
Signer* = ref object of RootObj
|
||||
populateLock: AsyncLock
|
||||
|
||||
template raiseSignerError*(message: string, parent: ref ProviderError = nil) =
|
||||
template raiseSignerError*(message: string, parent: ref CatchableError = nil) =
|
||||
raise newException(SignerError, message, parent)
|
||||
|
||||
template convertError(body) =
|
||||
@ -95,7 +95,10 @@ template withLock*(signer: Signer, body: untyped) =
|
||||
try:
|
||||
body
|
||||
finally:
|
||||
signer.populateLock.release()
|
||||
try:
|
||||
signer.populateLock.release()
|
||||
except AsyncLockError as e:
|
||||
raiseSignerError e.msg, e
|
||||
|
||||
method populateTransaction*(
|
||||
signer: Signer,
|
||||
@ -151,7 +154,7 @@ method populateTransaction*(
|
||||
method cancelTransaction*(
|
||||
signer: Signer,
|
||||
tx: Transaction
|
||||
): Future[TransactionResponse] {.base, async: (raises: [SignerError, CancelledError, AsyncLockError, ProviderError]).} =
|
||||
): Future[TransactionResponse] {.base, async: (raises: [SignerError, CancelledError, ProviderError]).} =
|
||||
# cancels a transaction by sending with a 0-valued transaction to ourselves
|
||||
# with the failed tx's nonce
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user