Commit 183df1a6 authored by miket@chromium.org's avatar miket@chromium.org

Provide a friendlier error message after Rietveld issue deletion.

As a n0oB to Chrome, I sometimes deleted uploaded CLs on codereview.chromium.org
after looking at them and deciding they were unsuitable for review. I
would then later git cl upload and get a confusing stacktrace about a
404. This change lets the user know why the error happened, and how to
resolve it.

I decided not to auto-scrub the old issue on the client side, because
the 404 might be spurious (server misconfiguration, bug in my code, etc.).
Safer to make the user explicitly run the command.

Review URL: http://codereview.chromium.org/9091009

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@116360 0039d316-1c4b-4281-b951-d872f2087c98
parent a3fcf209
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -446,8 +446,23 @@ or verify this branch is set up to track another (via the --track argument to ...@@ -446,8 +446,23 @@ or verify this branch is set up to track another (via the --track argument to
def GetDescription(self, pretty=False): def GetDescription(self, pretty=False):
if not self.has_description: if not self.has_description:
if self.GetIssue(): if self.GetIssue():
self.description = self.RpcServer().get_description( issue = int(self.GetIssue())
int(self.GetIssue())).strip() try:
self.description = self.RpcServer().get_description(issue).strip()
except urllib2.HTTPError, e:
if e.code == 404:
DieWithError(
('\nWhile fetching the description for issue %d, received a '
'404 (not found)\n'
'error. It is likely that you deleted this '
'issue on the server. If this is the\n'
'case, please run\n\n'
' git cl issue 0\n\n'
'to clear the association with the deleted issue. Then run '
'this command again.') % issue)
else:
DieWithError(
'\nFailed to fetch issue description. HTTP error ' + e.code)
self.has_description = True self.has_description = True
if pretty: if pretty:
wrapper = textwrap.TextWrapper() wrapper = textwrap.TextWrapper()
......
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