##// END OF EJS Templates
dispatch: sort exception handlers
Matt Mackall -
r7645:020a896a default
parent child Browse files
Show More
@@ -48,21 +48,11 b' def _runcatch(ui, args):'
48 48 ui.print_exc()
49 49 raise
50 50
51 except error.ParseError, inst:
52 if inst.args[0]:
53 ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
54 commands.help_(ui, inst.args[0])
55 else:
56 ui.warn(_("hg: %s\n") % inst.args[1])
57 commands.help_(ui, 'shortlist')
51 # Global exception handling, alphabetically
52 # Mercurial-specific first, followed by built-in and library exceptions
58 53 except error.AmbiguousCommand, inst:
59 54 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
60 55 (inst.args[0], " ".join(inst.args[1])))
61 except error.UnknownCommand, inst:
62 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
63 commands.help_(ui, 'shortlist')
64 except error.RepoError, inst:
65 ui.warn(_("abort: %s!\n") % inst)
66 56 except error.LockHeld, inst:
67 57 if inst.errno == errno.ETIMEDOUT:
68 58 reason = _('timed out waiting for lock held by %s') % inst.locker
@@ -72,21 +62,39 b' def _runcatch(ui, args):'
72 62 except error.LockUnavailable, inst:
73 63 ui.warn(_("abort: could not lock %s: %s\n") %
74 64 (inst.desc or inst.filename, inst.strerror))
65 except error.ParseError, inst:
66 if inst.args[0]:
67 ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
68 commands.help_(ui, inst.args[0])
69 else:
70 ui.warn(_("hg: %s\n") % inst.args[1])
71 commands.help_(ui, 'shortlist')
72 except error.RepoError, inst:
73 ui.warn(_("abort: %s!\n") % inst)
74 except error.ResponseError, inst:
75 ui.warn(_("abort: %s") % inst.args[0])
76 if not isinstance(inst.args[1], basestring):
77 ui.warn(" %r\n" % (inst.args[1],))
78 elif not inst.args[1]:
79 ui.warn(_(" empty string\n"))
80 else:
81 ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
75 82 except error.RevlogError, inst:
76 83 ui.warn(_("abort: %s!\n") % inst)
77 84 except error.SignalInterrupt:
78 85 ui.warn(_("killed!\n"))
79 except KeyboardInterrupt:
80 try:
81 ui.warn(_("interrupted!\n"))
82 except IOError, inst:
83 if inst.errno == errno.EPIPE:
84 if ui.debugflag:
85 ui.warn(_("\nbroken pipe\n"))
86 else:
87 raise
88 except socket.error, inst:
89 ui.warn(_("abort: %s\n") % inst.args[-1])
86 except error.UnknownCommand, inst:
87 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
88 commands.help_(ui, 'shortlist')
89 except util.Abort, inst:
90 ui.warn(_("abort: %s\n") % inst)
91 except ImportError, inst:
92 m = str(inst).split()[-1]
93 ui.warn(_("abort: could not import module %s!\n") % m)
94 if m in "mpatch bdiff".split():
95 ui.warn(_("(did you forget to compile extensions?)\n"))
96 elif m in "zlib".split():
97 ui.warn(_("(is your Python install correct?)\n"))
90 98 except IOError, inst:
91 99 if hasattr(inst, "code"):
92 100 ui.warn(_("abort: %s\n") % inst)
@@ -111,30 +119,23 b' def _runcatch(ui, args):'
111 119 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
112 120 else:
113 121 ui.warn(_("abort: %s\n") % inst.strerror)
114 except error.ResponseError, inst:
115 ui.warn(_("abort: %s") % inst.args[0])
116 if not isinstance(inst.args[1], basestring):
117 ui.warn(" %r\n" % (inst.args[1],))
118 elif not inst.args[1]:
119 ui.warn(_(" empty string\n"))
122 except KeyboardInterrupt:
123 try:
124 ui.warn(_("interrupted!\n"))
125 except IOError, inst:
126 if inst.errno == errno.EPIPE:
127 if ui.debugflag:
128 ui.warn(_("\nbroken pipe\n"))
120 129 else:
121 ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
122 except ImportError, inst:
123 m = str(inst).split()[-1]
124 ui.warn(_("abort: could not import module %s!\n") % m)
125 if m in "mpatch bdiff".split():
126 ui.warn(_("(did you forget to compile extensions?)\n"))
127 elif m in "zlib".split():
128 ui.warn(_("(is your Python install correct?)\n"))
129
130 except util.Abort, inst:
131 ui.warn(_("abort: %s\n") % inst)
130 raise
132 131 except MemoryError:
133 132 ui.warn(_("abort: out of memory\n"))
134 133 except SystemExit, inst:
135 134 # Commands shouldn't sys.exit directly, but give a return code.
136 135 # Just in case catch this and and pass exit code to caller.
137 136 return inst.code
137 except socket.error, inst:
138 ui.warn(_("abort: %s\n") % inst.args[-1])
138 139 except:
139 140 ui.warn(_("** unknown exception encountered, details follow\n"))
140 141 ui.warn(_("** report bug details to "
General Comments 0
You need to be logged in to leave comments. Login now