error catching for edge cases and poorly formatted params

This commit is contained in:
Josh Burman
2021-12-16 19:01:59 +00:00
parent 04ab475a36
commit dc696b47ac
2 changed files with 33 additions and 23 deletions

View File

@ -1,7 +1,11 @@
from pulp import lpSum
from random import randint, sample
import logging
from lib.errors.item_generation_error import ItemGenerationError
def build_constraints(solver_run, problem, items):
try:
total_form_items = solver_run.total_form_items
constraints = solver_run.constraints
@ -30,3 +34,6 @@ def build_constraints(solver_run, problem, items):
return problem
except ValueError as error:
logging.error(error)
raise ItemGenerationError("Bundle min and/or max larger than bundle amount provided", error.args[0])

View File

@ -19,6 +19,9 @@ class LoftService(Base):
self.result = self.stream_to_s3_bucket()
except ItemGenerationError as error:
self.result = self.stream_to_s3_bucket(error)
except TypeError as error:
logging.error(error)
self.result = self.stream_to_s3_bucket(ItemGenerationError("Provided params causing error in calculation results"))
def retreive_attributes_from_message(self):
logging.info('Retrieving attributes from message...')