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

Benjamin Renard commited on 2012-04-20 15:22:11
Showing 1 changed files, with 13 additions and 2 deletions.

... ...
@@ -50,9 +50,20 @@ class MantisWS(object):
50 50
 		try:
51 51
 			res = self.client.service.mc_issue_note_add(self.user,self.password,issue_id,note)
52 52
 			return res
53
-		except:
54
-			logging.error('Problem adding note to issue %s' % issue_id)
53
+		except suds.WebFault, e:
54
+			logging.error('Problem adding note to issue %s : %s' % (issue_id,e))
55
+			err=str(e)
56
+			if re.search('Issue .* does not exist.',err):
57
+				logging.error('The issue %s does not exists' % issue_id)
58
+				raise MantisWSError('unknown_issue_note_add','The issue %s does not exists' % issue_id)
59
+			else:
60
+				raise MantisWSError('general_note_add','Problem adding note to issue %s : e' % (issue_id,e))
55 61
 			return None
62
+		except Exception, e:
63
+			logging.error('Problem adding note to issue %s : %s' % (issue_id,e))
64
+			raise MantisWSError('general_note_add','Problem adding note to issue %s : e' % (issue_id,e))
65
+			return None
66
+
56 67
 	def add_attachment_to_issue(self,issue_id,attachment):
57 68
 		try:
58 69
 			res = self.client.service.mc_issue_attachment_add(
59 70