mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-02-28 14:20:36 +00:00
* fix(statemachine): do not raise from state.run * fix rebase * fix exception handling in SaleProvingSimulated.prove - re-raise CancelledError - don't return State on CatchableError - expect the Proofs_InvalidProof custom error instead of checking a string * asyncSpawn salesagent.onCancelled This was swallowing a KeyError in one of the tests (fixed in the previous commit) * remove error handling states in asyncstatemachine * revert unneeded changes * formatting * PR feedback, logging updates
42 lines
1.1 KiB
Nim
42 lines
1.1 KiB
Nim
import pkg/questionable
|
|
import pkg/questionable/results
|
|
import pkg/upraises
|
|
|
|
import ../statemachine
|
|
import ../salesagent
|
|
import ../../logutils
|
|
import ../../utils/exceptions
|
|
|
|
logScope:
|
|
topics = "marketplace sales errored"
|
|
|
|
type SaleErrored* = ref object of SaleState
|
|
error*: ref CatchableError
|
|
reprocessSlot*: bool
|
|
|
|
method `$`*(state: SaleErrored): string =
|
|
"SaleErrored"
|
|
|
|
method run*(
|
|
state: SaleErrored, machine: Machine
|
|
): Future[?State] {.async: (raises: []).} =
|
|
let agent = SalesAgent(machine)
|
|
let data = agent.data
|
|
let context = agent.context
|
|
|
|
error "Sale error",
|
|
error = state.error.msgDetail,
|
|
requestId = data.requestId,
|
|
slotIndex = data.slotIndex
|
|
|
|
try:
|
|
if onClear =? context.onClear and request =? data.request:
|
|
onClear(request, data.slotIndex)
|
|
|
|
if onCleanUp =? agent.onCleanUp:
|
|
await onCleanUp(returnBytes = true, reprocessSlot = state.reprocessSlot)
|
|
except CancelledError as e:
|
|
trace "SaleErrored.run was cancelled", error = e.msgDetail
|
|
except CatchableError as e:
|
|
error "Error during SaleErrored.run", error = e.msgDetail
|