mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-22 00:30:37 +00:00
Use custom error message (#1079)
This commit is contained in:
parent
ac12de37b2
commit
389ab59aa7
@ -42,7 +42,7 @@ method run*(state: SaleSlotReserving, machine: Machine): Future[?State] {.async.
|
||||
trace "Reserving slot"
|
||||
await market.reserveSlot(data.requestId, data.slotIndex)
|
||||
except MarketError as e:
|
||||
if e.msg.contains "Reservation not allowed":
|
||||
if e.msg.contains "SlotReservations_ReservationNotAllowed":
|
||||
debug "Slot cannot be reserved, ignoring", error = e.msg
|
||||
return some State( SaleIgnored(reprocessSlot: false, returnBytes: true) )
|
||||
else:
|
||||
|
@ -65,3 +65,11 @@ asyncchecksuite "sales state 'SlotReserving'":
|
||||
check next of SaleErrored
|
||||
let errored = SaleErrored(next)
|
||||
check errored.error == error
|
||||
|
||||
test "catches reservation not allowed error":
|
||||
let error = newException(MarketError, "SlotReservations_ReservationNotAllowed")
|
||||
market.setReserveSlotThrowError(some error)
|
||||
let next = !(await state.run(agent))
|
||||
check next of SaleIgnored
|
||||
check SaleIgnored(next).reprocessSlot == false
|
||||
check SaleIgnored(next).returnBytes
|
Loading…
x
Reference in New Issue
Block a user