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