From 411193988d3daef5adc3235e23126fd90e6bc05a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartek=20G=C3=B3rny?= <bartek@gorny.edu.pl>
Date: Wed, 27 Sep 2006 14:16:19 +0000
Subject: [PATCH] optionally raise exceptions instead of returning error
 message

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10360 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../ERP5OOo/Constraint/DocumentCoordinatesConstraint.py   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/product/ERP5OOo/Constraint/DocumentCoordinatesConstraint.py b/product/ERP5OOo/Constraint/DocumentCoordinatesConstraint.py
index 24f0e6e3cc..197e7a4969 100644
--- a/product/ERP5OOo/Constraint/DocumentCoordinatesConstraint.py
+++ b/product/ERP5OOo/Constraint/DocumentCoordinatesConstraint.py
@@ -39,7 +39,7 @@ class DocumentCoordinatesConstraint(Constraint):
   we do not fix (although we could, e.g. change version number)
   """
 
-  def checkConsistency(self, o, fixit=0):
+  def checkConsistency(self, o, fixit=0, throw=False):
     """Implement here the consistency checker
     """
     errors = []
@@ -49,6 +49,8 @@ class DocumentCoordinatesConstraint(Constraint):
         s='%s is None  ' % req
         errors.append(self._generateError(o, N_(s)))
     if errors:
+      if throw:
+        raise Exception(str(errors))
       return errors
     res=o.portal_catalog(reference=o.getReference(),language=o.getLanguage(),version=o.getVersion(),portal_type=o.getPortalDocumentTypeList())
     res=list(res)
@@ -57,7 +59,9 @@ class DocumentCoordinatesConstraint(Constraint):
       errors.append(self._generateError(o, N_(s)))
     if len(res)>2: # this is very serious
       raise Exception('Fatal error: multiple objects %s - %s - %s exist' % (o.getReference(),o.getLanguage(),o.getVersion()))
-      errors.append(self._generateError(o, N_(s)))
+      #errors.append(self._generateError(o, N_(s)))
+    if errors and throw:
+      raise Exception(str(errors))
     return errors
 
 
-- 
2.30.9