##// END OF EJS Templates
extensions: tapdance to get reasonable import error formatting...
Augie Fackler -
r31303:90f43982 default
parent child Browse files
Show More
@@ -18,6 +18,7 b' from .i18n import ('
18 18
19 19 from . import (
20 20 cmdutil,
21 encoding,
21 22 error,
22 23 pycompat,
23 24 util,
@@ -104,11 +105,18 b' def _importext(name, path=None, reportfu'
104 105 mod = _importh(name)
105 106 return mod
106 107
108 def _forbytes(inst):
109 """Portably format an import error into a form suitable for
110 %-formatting into bytestrings."""
111 if pycompat.ispy3:
112 return encoding.tolocal(str(inst).encode('utf-8'))
113 return inst
114
107 115 def _reportimporterror(ui, err, failed, next):
108 116 # note: this ui.debug happens before --debug is processed,
109 117 # Use --config ui.debug=1 to see them.
110 118 ui.debug('could not import %s (%s): trying %s\n'
111 % (failed, err, next))
119 % (failed, _forbytes(err), next))
112 120 if ui.debugflag:
113 121 ui.traceback()
114 122
@@ -168,6 +176,7 b' def loadall(ui):'
168 176 except KeyboardInterrupt:
169 177 raise
170 178 except Exception as inst:
179 inst = _forbytes(inst)
171 180 if path:
172 181 ui.warn(_("*** failed to import extension %s from %s: %s\n")
173 182 % (name, path, inst))
General Comments 0
You need to be logged in to leave comments. Login now