Commit 7bd150b9 authored by Sebastien Robin's avatar Sebastien Robin

use class Exception instead of string


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4631 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2bacf683
...@@ -36,6 +36,9 @@ from Products.ERP5.Document.OrderBuilder import OrderBuilder ...@@ -36,6 +36,9 @@ from Products.ERP5.Document.OrderBuilder import OrderBuilder
from zLOG import LOG from zLOG import LOG
class SelectMethodError(Exception): pass
class SelectMovementError(Exception): pass
class DeliveryBuilder(OrderBuilder): class DeliveryBuilder(OrderBuilder):
""" """
Delivery Builder objects allow to gather multiple Simulation Movements Delivery Builder objects allow to gather multiple Simulation Movements
...@@ -134,7 +137,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -134,7 +137,7 @@ class DeliveryBuilder(OrderBuilder):
mvt_dict = {} mvt_dict = {}
for movement in movement_list: for movement in movement_list:
if mvt_dict.has_key(movement): if mvt_dict.has_key(movement):
raise "SelectMethodError", \ raise SelectMethodError, \
"%s return %s twice (or more)" % \ "%s return %s twice (or more)" % \
(str(self.simulation_select_method_id), (str(self.simulation_select_method_id),
str(movement.getRelativeUrl())) str(movement.getRelativeUrl()))
...@@ -159,7 +162,7 @@ class DeliveryBuilder(OrderBuilder): ...@@ -159,7 +162,7 @@ class DeliveryBuilder(OrderBuilder):
# Check if simulation movement is not already linked to a existing # Check if simulation movement is not already linked to a existing
# movement # movement
if simulation_movement.getDeliveryValue() is not None: if simulation_movement.getDeliveryValue() is not None:
raise "SelectMovementError",\ raise SelectMovementError,\
"simulation_movement '%s' must not be selected !" %\ "simulation_movement '%s' must not be selected !" %\
simulation_movement.getRelativeUrl() simulation_movement.getRelativeUrl()
# Update simulation movement # Update simulation movement
......
...@@ -36,6 +36,9 @@ from Products.ERP5Type.Utils import convertToUpperCase ...@@ -36,6 +36,9 @@ from Products.ERP5Type.Utils import convertToUpperCase
from DateTime import DateTime from DateTime import DateTime
from zLOG import LOG from zLOG import LOG
class CollectError(Exception): pass
class MatrixError(Exception): pass
class OrderBuilder(XMLObject, Amount, Predicate): class OrderBuilder(XMLObject, Amount, Predicate):
""" """
Order Builder objects allow to gather multiple Simulation Movements Order Builder objects allow to gather multiple Simulation Movements
...@@ -441,7 +444,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -441,7 +444,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
else: else:
movement_list = movement_group.getMovementList() movement_list = movement_group.getMovementList()
if len(movement_list) != 1: if len(movement_list) != 1:
raise "CollectError", "DeliveryBuilder: %s unable to distinct those\ raise CollectError, "DeliveryBuilder: %s unable to distinct those\
movements: %s" % (self.getId(), str(movement_list)) movements: %s" % (self.getId(), str(movement_list))
else: else:
# XXX Hardcoded value # XXX Hardcoded value
...@@ -489,7 +492,7 @@ class OrderBuilder(XMLObject, Amount, Predicate): ...@@ -489,7 +492,7 @@ class OrderBuilder(XMLObject, Amount, Predicate):
getVariationBaseCategoryList()) getVariationBaseCategoryList())
object_to_update = cell object_to_update = cell
else: else:
raise 'MatrixError', 'Cell: %s already exists on %s' % \ raise MatrixError, 'Cell: %s already exists on %s' % \
(str(cell_key), str(delivery_line)) (str(cell_key), str(delivery_line))
self._setDeliveryMovementProperties( self._setDeliveryMovementProperties(
object_to_update, movement, property_dict, object_to_update, movement, property_dict,
......
...@@ -38,6 +38,8 @@ from Products.ERP5.Document.TransformationSourcingRule import\ ...@@ -38,6 +38,8 @@ from Products.ERP5.Document.TransformationSourcingRule import\
from zLOG import LOG from zLOG import LOG
class TransformationRuleError(Exception): pass
class TransformationRule(Rule): class TransformationRule(Rule):
""" """
Order Rule object make sure an Order in the similation Order Rule object make sure an Order in the similation
...@@ -92,7 +94,7 @@ class TransformationRule(Rule): ...@@ -92,7 +94,7 @@ class TransformationRule(Rule):
elif length > 1: elif length > 1:
result = 0 result = 0
# XXX FIXME: implementation needed # XXX FIXME: implementation needed
raise "TransformationRuleError",\ raise TransformationRuleError,\
"TransformationRule not able to use multiple SupplyLink." "TransformationRule not able to use multiple SupplyLink."
return result return result
...@@ -118,7 +120,7 @@ class TransformationRule(Rule): ...@@ -118,7 +120,7 @@ class TransformationRule(Rule):
if len(current_supply_link_list) != 1: if len(current_supply_link_list) != 1:
# We shall no pass here. # We shall no pass here.
# The test method returned a wrong value ! # The test method returned a wrong value !
raise "TransformationRuleError",\ raise TransformationRuleError,\
"Expand must not be called on %r" %\ "Expand must not be called on %r" %\
applied_rule.getRelativeUrl() applied_rule.getRelativeUrl()
else: else:
......
...@@ -38,6 +38,9 @@ from Products.ERP5.Document.Rule import Rule ...@@ -38,6 +38,9 @@ from Products.ERP5.Document.Rule import Rule
from zLOG import LOG from zLOG import LOG
class ProductionOrderError(Exception): pass
class TransformationSourcingRuleError(Exception): pass
class TransformationSourcingRuleMixin(ExtensionClass.Base): class TransformationSourcingRuleMixin(ExtensionClass.Base):
""" """
Mixin class used by TransformationSourcingRule and TransformationRule Mixin class used by TransformationSourcingRule and TransformationRule
...@@ -57,7 +60,7 @@ class TransformationSourcingRuleMixin(ExtensionClass.Base): ...@@ -57,7 +60,7 @@ class TransformationSourcingRuleMixin(ExtensionClass.Base):
supply_chain = order.getSpecialiseValue( supply_chain = order.getSpecialiseValue(
portal_type=supply_chain_portal_type) portal_type=supply_chain_portal_type)
if supply_chain is None: if supply_chain is None:
raise "ProductionOrderError",\ raise ProductionOrderError,\
"No SupplyChain defined on %s" % str(order) "No SupplyChain defined on %s" % str(order)
else: else:
return supply_chain return supply_chain
...@@ -197,7 +200,7 @@ class TransformationSourcingRule(Rule): ...@@ -197,7 +200,7 @@ class TransformationSourcingRule(Rule):
parent_supply_link, parent_supply_link,
movement=parent_movement) movement=parent_movement)
if len(previous_supply_link_list) == 0: if len(previous_supply_link_list) == 0:
raise "TransformationSourcingRuleError",\ raise TransformationSourcingRuleError,\
"Expand must not be called on %r" %\ "Expand must not be called on %r" %\
applied_rule.getRelativeUrl() applied_rule.getRelativeUrl()
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment