+

MantisWS : improve error log of add_note_to_issue() and raise exception on error

Benjamin Renard [2012-04-20 15:22:11]
MantisWS : improve error log of add_note_to_issue() and raise exception on error
Filename
src/usr/share/mantis-smtp/MantisWS.py
diff --git a/src/usr/share/mantis-smtp/MantisWS.py b/src/usr/share/mantis-smtp/MantisWS.py
index 16fe0ef..4f1d5e0 100755
--- a/src/usr/share/mantis-smtp/MantisWS.py
+++ b/src/usr/share/mantis-smtp/MantisWS.py
@@ -50,9 +50,20 @@ class MantisWS(object):
 		try:
 			res = self.client.service.mc_issue_note_add(self.user,self.password,issue_id,note)
 			return res
-		except:
-			logging.error('Problem adding note to issue %s' % issue_id)
+		except suds.WebFault, e:
+			logging.error('Problem adding note to issue %s : %s' % (issue_id,e))
+			err=str(e)
+			if re.search('Issue .* does not exist.',err):
+				logging.error('The issue %s does not exists' % issue_id)
+				raise MantisWSError('unknown_issue_note_add','The issue %s does not exists' % issue_id)
+			else:
+				raise MantisWSError('general_note_add','Problem adding note to issue %s : e' % (issue_id,e))
 			return None
+		except Exception, e:
+			logging.error('Problem adding note to issue %s : %s' % (issue_id,e))
+			raise MantisWSError('general_note_add','Problem adding note to issue %s : e' % (issue_id,e))
+			return None
+
 	def add_attachment_to_issue(self,issue_id,attachment):
 		try:
 			res = self.client.service.mc_issue_attachment_add(
ViewGit