Use custom error message (#1079)

This commit is contained in:
Arnaud 2025-01-20 17:04:50 +01:00 committed by GitHub
parent ac12de37b2
commit 389ab59aa7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -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:

View File

@ -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