error catching for edge cases and poorly formatted params
This commit is contained in:
@ -1,7 +1,11 @@
|
|||||||
from pulp import lpSum
|
from pulp import lpSum
|
||||||
from random import randint, sample
|
from random import randint, sample
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from lib.errors.item_generation_error import ItemGenerationError
|
||||||
|
|
||||||
def build_constraints(solver_run, problem, items):
|
def build_constraints(solver_run, problem, items):
|
||||||
|
try:
|
||||||
total_form_items = solver_run.total_form_items
|
total_form_items = solver_run.total_form_items
|
||||||
constraints = solver_run.constraints
|
constraints = solver_run.constraints
|
||||||
|
|
||||||
@ -30,3 +34,6 @@ def build_constraints(solver_run, problem, items):
|
|||||||
|
|
||||||
|
|
||||||
return problem
|
return problem
|
||||||
|
except ValueError as error:
|
||||||
|
logging.error(error)
|
||||||
|
raise ItemGenerationError("Bundle min and/or max larger than bundle amount provided", error.args[0])
|
||||||
|
@ -19,6 +19,9 @@ class LoftService(Base):
|
|||||||
self.result = self.stream_to_s3_bucket()
|
self.result = self.stream_to_s3_bucket()
|
||||||
except ItemGenerationError as error:
|
except ItemGenerationError as error:
|
||||||
self.result = self.stream_to_s3_bucket(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):
|
def retreive_attributes_from_message(self):
|
||||||
logging.info('Retrieving attributes from message...')
|
logging.info('Retrieving attributes from message...')
|
||||||
|
Reference in New Issue
Block a user