# HG changeset patch # User Pierre-Yves David # Date 2021-11-26 15:55:34 # Node ID e4e2ce328599ec885c76cc2943db1595bcd040fb # Parent c6d44457f7e318192c6a3251894874a4165bcf30 extensions: refactor handling of loading error make it reusable We will need this in the next patch. Differential Revision: https://phab.mercurial-scm.org/D11820 diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -307,15 +307,12 @@ def loadall(ui, whitelist=None): except Exception as inst: msg = stringutil.forcebytestr(inst) if path: - ui.warn( - _(b"*** failed to import extension %s from %s: %s\n") - % (name, path, msg) - ) + error_msg = _(b"failed to import extension %s from %s: %s") + error_msg %= (name, path, msg) else: - ui.warn( - _(b"*** failed to import extension %s: %s\n") - % (name, msg) - ) + error_msg = _(b"failed to import extension %s: %s") + error_msg %= (name, msg) + ui.warn((b"*** %s\n") % error_msg) if isinstance(inst, error.Hint) and inst.hint: ui.warn(_(b"*** (%s)\n") % inst.hint) ui.traceback()