@@ -58,36 +58,45 @@ function validateType(event: unknown) {
5858}
5959
6060async function getSupplierFromConfig ( letterEvent : PreparedEvents , deps : Deps ) {
61- const variantDetails : LetterVariant = await getVariantDetails (
62- letterEvent . data . letterVariantId ,
63- deps ,
64- ) ;
65-
66- const volumeGroupDetails : VolumeGroup = await getVolumeGroupDetails (
67- variantDetails . volumeGroupId ,
68- deps ,
69- ) ;
70-
71- const supplierAllocations : SupplierAllocation [ ] =
72- await getSupplierAllocationsForVolumeGroup (
61+ try {
62+ const variantDetails : LetterVariant = await getVariantDetails (
63+ letterEvent . data . letterVariantId ,
64+ deps ,
65+ ) ;
66+
67+ const volumeGroupDetails : VolumeGroup = await getVolumeGroupDetails (
7368 variantDetails . volumeGroupId ,
7469 deps ,
75- variantDetails . supplierId ,
7670 ) ;
7771
78- const supplierDetails : Supplier [ ] = await getSupplierDetails (
79- supplierAllocations ,
80- deps ,
81- ) ;
82- deps . logger . info ( {
83- description : "Fetched supplier details for supplier allocations" ,
84- variantId : letterEvent . data . letterVariantId ,
85- volumeGroupId : volumeGroupDetails . id ,
86- supplierAllocationIds : supplierAllocations . map ( ( a ) => a . id ) ,
87- supplierDetails,
88- } ) ;
72+ const supplierAllocations : SupplierAllocation [ ] =
73+ await getSupplierAllocationsForVolumeGroup (
74+ variantDetails . volumeGroupId ,
75+ deps ,
76+ variantDetails . supplierId ,
77+ ) ;
78+
79+ const supplierDetails : Supplier [ ] = await getSupplierDetails (
80+ supplierAllocations ,
81+ deps ,
82+ ) ;
83+ deps . logger . info ( {
84+ description : "Fetched supplier details for supplier allocations" ,
85+ variantId : letterEvent . data . letterVariantId ,
86+ volumeGroupId : volumeGroupDetails . id ,
87+ supplierAllocationIds : supplierAllocations . map ( ( a ) => a . id ) ,
88+ supplierDetails,
89+ } ) ;
8990
90- return supplierDetails ;
91+ return supplierDetails ;
92+ } catch ( error ) {
93+ deps . logger . error ( {
94+ description : "Error fetching supplier from config" ,
95+ err : error ,
96+ variantId : letterEvent . data . letterVariantId ,
97+ } ) ;
98+ return [ ] ;
99+ }
91100}
92101
93102function getSupplier ( letterEvent : PreparedEvents , deps : Deps ) : SupplierSpec {
0 commit comments