2023-07-20 07:56:28 +00:00
|
|
|
import pkg/metrics
|
2022-09-27 14:27:40 +00:00
|
|
|
import ../statemachine
|
2023-10-19 08:12:49 +00:00
|
|
|
import ../../utils/exceptions
|
2023-12-19 22:12:47 +00:00
|
|
|
import ../../logutils
|
2022-09-27 14:27:40 +00:00
|
|
|
|
2023-11-03 15:21:54 +00:00
|
|
|
declareCounter(codex_purchases_error, "codex purchases error")
|
2023-07-20 07:56:28 +00:00
|
|
|
|
2023-10-19 08:12:49 +00:00
|
|
|
logScope:
|
|
|
|
topics = "marketplace purchases errored"
|
|
|
|
|
2022-11-08 07:10:17 +00:00
|
|
|
type PurchaseErrored* = ref object of PurchaseState
|
2022-09-27 14:27:40 +00:00
|
|
|
error*: ref CatchableError
|
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
method `$`*(state: PurchaseErrored): string =
|
|
|
|
"errored"
|
2022-09-27 14:27:40 +00:00
|
|
|
|
2023-06-05 08:48:06 +00:00
|
|
|
method run*(state: PurchaseErrored, machine: Machine): Future[?State] {.async.} =
|
2023-11-03 15:21:54 +00:00
|
|
|
codex_purchases_error.inc()
|
2023-06-05 08:48:06 +00:00
|
|
|
let purchase = Purchase(machine)
|
2023-10-19 08:12:49 +00:00
|
|
|
|
|
|
|
error "Purchasing error", error=state.error.msgDetail, requestId = purchase.requestId
|
|
|
|
|
2022-09-27 14:27:40 +00:00
|
|
|
purchase.future.fail(state.error)
|