@@ -84,7 +84,10 @@ def chain_revisions(parent_rev, child_rev):
8484 cmd += " | %s call-conduit --conduit-uri=%s differential.revision.search --" "" % (_arc (), self .url )
8585
8686 ret = self .run (cmd , shell = True )
87- result = json .loads (ret .stdout .decode ())
87+ try :
88+ result = json .loads (ret .stdout .decode ())
89+ except Exception :
90+ raise Exception ("Could not decode response as JSON: %s" % ret .stdout .decode ())
8891
8992 if result ['error' ]:
9093 raise Exception ("Got an error from phabricator when trying to search for %s" % (child_rev ))
@@ -101,7 +104,10 @@ def chain_revisions(parent_rev, child_rev):
101104 cmd = "echo " + quote_echo_string ("""{"transactions": [{"type":"parents.add", "value":["%s"]}], "objectIdentifier": "%s"}""" % (child_phid , parent_rev ))
102105 cmd += " | %s call-conduit --conduit-uri=%s differential.revision.edit --" "" % (_arc (), self .url )
103106 ret = self .run (cmd , shell = True )
104- result = json .loads (ret .stdout .decode ())
107+ try :
108+ result = json .loads (ret .stdout .decode ())
109+ except Exception :
110+ raise Exception ("Could not decode response as JSON: %s" % ret .stdout .decode ())
105111 if result ['error' ]:
106112 raise Exception ("Got an error from phabricator when trying chain revisions, parent: %s, child %s %s" % (parent_rev , child_rev , child_phid ))
107113
@@ -116,7 +122,10 @@ def associate_bug_id(phab_revision):
116122 cmd = "echo " + quote_echo_string ("""{"transactions": [{"type":"bugzilla.bug-id", "value":"%s"}], "objectIdentifier": "%s"}""" % (bug_id , phab_revision ))
117123 cmd += " | %s call-conduit --conduit-uri=%s differential.revision.edit --" "" % (_arc (), self .url )
118124 ret = self .run (cmd , shell = True )
119- result = json .loads (ret .stdout .decode ())
125+ try :
126+ result = json .loads (ret .stdout .decode ())
127+ except Exception :
128+ raise Exception ("Could not decode response as JSON: %s" % ret .stdout .decode ())
120129 if result ['error' ]:
121130 raise Exception ("Got an error from phabricator when trying to set the bugzilla id for %s" % (phab_revision ))
122131
@@ -142,7 +151,10 @@ def set_reviewer(self, phab_revision, phab_username):
142151 cmd += " | %s call-conduit --conduit-uri=%s user.search --" "" % (_arc (), self .url )
143152
144153 ret = self .run (cmd , shell = True )
145- result = json .loads (ret .stdout .decode ())
154+ try :
155+ result = json .loads (ret .stdout .decode ())
156+ except Exception :
157+ raise Exception ("Could not decode response as JSON: %s" % ret .stdout .decode ())
146158
147159 if result ['error' ]:
148160 raise Exception ("Got an error from phabricator when trying to search for %s" % (phab_username ))
@@ -158,7 +170,10 @@ def set_reviewer(self, phab_revision, phab_username):
158170 cmd = "echo " + quote_echo_string ("""{"transactions": [{"type":"reviewers.set", "value":["%s"]}], "objectIdentifier": "%s"}""" % (phid , phab_revision ))
159171 cmd += " | %s call-conduit --conduit-uri=%s differential.revision.edit --" "" % (_arc (), self .url )
160172 ret = self .run (cmd , shell = True )
161- result = json .loads (ret .stdout .decode ())
173+ try :
174+ result = json .loads (ret .stdout .decode ())
175+ except Exception :
176+ raise Exception ("Could not decode response as JSON: %s" % ret .stdout .decode ())
162177 if result ['error' ]:
163178 raise Exception ("Got an error from phabricator when trying to set reviewers to %s (%s) for %s: %s" % (phab_username , phid , phab_revision , result ))
164179
@@ -168,7 +183,10 @@ def abandon(self, phab_revision):
168183 cmd = "echo " + quote_echo_string ("""{"transactions": [{"type":"abandon", "value":true}],"objectIdentifier": "%s"}""" % phab_revision )
169184 cmd += " | %s call-conduit --conduit-uri=%s differential.revision.edit --" "" % (_arc (), self .url )
170185 ret = self .run (cmd , shell = True )
171- result = json .loads (ret .stdout .decode ())
186+ try :
187+ result = json .loads (ret .stdout .decode ())
188+ except Exception :
189+ raise Exception ("Could not decode response as JSON: %s" % ret .stdout .decode ())
172190 if result ['error' ]:
173191 if "You can not abandon this revision because it has already been closed." in result ['errorMessage' ]:
174192 self .logger .log ("Strangely, the phabricator revision %s was already closed when we tried to abandon it. Oh well." % phab_revision , level = LogLevel .Warning )
0 commit comments