@@ -65,36 +65,45 @@ function validateType(event: unknown) {
6565}
6666
6767async function getSupplierFromConfig ( letterEvent : PreparedEvents , deps : Deps ) {
68- const variantDetails : LetterVariant = await getVariantDetails (
69- letterEvent . data . letterVariantId ,
70- deps ,
71- ) ;
72-
73- const volumeGroupDetails : VolumeGroup = await getVolumeGroupDetails (
74- variantDetails . volumeGroupId ,
75- deps ,
76- ) ;
77-
78- const supplierAllocations : SupplierAllocation [ ] =
79- await getSupplierAllocationsForVolumeGroup (
68+ try {
69+ const variantDetails : LetterVariant = await getVariantDetails (
70+ letterEvent . data . letterVariantId ,
71+ deps ,
72+ ) ;
73+
74+ const volumeGroupDetails : VolumeGroup = await getVolumeGroupDetails (
8075 variantDetails . volumeGroupId ,
8176 deps ,
82- variantDetails . supplierId ,
8377 ) ;
8478
85- const supplierDetails : Supplier [ ] = await getSupplierDetails (
86- supplierAllocations ,
87- deps ,
88- ) ;
89- deps . logger . info ( {
90- description : "Fetched supplier details for supplier allocations" ,
91- variantId : letterEvent . data . letterVariantId ,
92- volumeGroupId : volumeGroupDetails . id ,
93- supplierAllocationIds : supplierAllocations . map ( ( a ) => a . id ) ,
94- supplierDetails,
95- } ) ;
79+ const supplierAllocations : SupplierAllocation [ ] =
80+ await getSupplierAllocationsForVolumeGroup (
81+ variantDetails . volumeGroupId ,
82+ deps ,
83+ variantDetails . supplierId ,
84+ ) ;
85+
86+ const supplierDetails : Supplier [ ] = await getSupplierDetails (
87+ supplierAllocations ,
88+ deps ,
89+ ) ;
90+ deps . logger . info ( {
91+ description : "Fetched supplier details for supplier allocations" ,
92+ variantId : letterEvent . data . letterVariantId ,
93+ volumeGroupId : volumeGroupDetails . id ,
94+ supplierAllocationIds : supplierAllocations . map ( ( a ) => a . id ) ,
95+ supplierDetails,
96+ } ) ;
9697
97- return supplierDetails ;
98+ return supplierDetails ;
99+ } catch ( error ) {
100+ deps . logger . error ( {
101+ description : "Error fetching supplier from config" ,
102+ err : error ,
103+ variantId : letterEvent . data . letterVariantId ,
104+ } ) ;
105+ return [ ] ;
106+ }
98107}
99108
100109function getSupplier ( letterEvent : PreparedEvents , deps : Deps ) : SupplierSpec {
0 commit comments