changeset 48407:e4e2ce328599

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
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 26 Nov 2021 16:55:34 +0100
parents c6d44457f7e3
children e4acdf5d94a2
files mercurial/extensions.py
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/extensions.py	Fri Nov 26 16:51:58 2021 +0100
+++ b/mercurial/extensions.py	Fri Nov 26 16:55:34 2021 +0100
@@ -307,15 +307,12 @@
             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()