From 26104b1e44826a8a8b162d3022a33f4bd9d4d397 Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Thu, 19 Dec 2024 12:30:33 +1100 Subject: [PATCH] fix(place/demo/lockers): add debugging info when parsing in configuration --- drivers/place/attendee_scanner_spec.cr | 18 +++++++++--------- drivers/place/demo/lockers.cr | 7 ++++++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/place/attendee_scanner_spec.cr b/drivers/place/attendee_scanner_spec.cr index 91752b0a87..2437f1bfff 100644 --- a/drivers/place/attendee_scanner_spec.cr +++ b/drivers/place/attendee_scanner_spec.cr @@ -10,15 +10,6 @@ class LocationServices < DriverSpecs::MockDriver self[:building_id_requested] = true "zone-building" end - - def systems - self[:systems_requested] = true - { - "zone-level1": [ - "spec_runner_system", - ], - } - end end # :nodoc: @@ -33,6 +24,15 @@ class StaffAPI < DriverSpecs::MockDriver } end + def systems_in_building(zone_id : String, ids_only : Bool = true) + self[:systems_requested] = zone_id + { + "zone-level1": [ + "spec_runner_system", + ], + } + end + def get_system(id : String, complete : Bool = false) raise "unexpected system requested #{id}" unless id == "spec_runner_system" diff --git a/drivers/place/demo/lockers.cr b/drivers/place/demo/lockers.cr index 275e0aead0..81867ec24a 100644 --- a/drivers/place/demo/lockers.cr +++ b/drivers/place/demo/lockers.cr @@ -75,7 +75,12 @@ class Place::Demo::Lockers < PlaceOS::Driver def lockers_details(level_id : String) : Array(LockerBank) lockers = staff_api.metadata(level_id, "lockers").get.dig?("lockers", "details") return [] of LockerBank unless lockers - Array(LockerBank).from_json(lockers.to_json) + begin + Array(LockerBank).from_json(lockers.to_json) + rescue error + logger.warn(exception: error) { "error parsing locker json on level #{level_id}:\n#{lockers.to_pretty_json}" } + [] of LockerBank + end end class ::PlaceOS::Driver::Interface::Lockers::PlaceLocker