Commit 2ebbff83 authored by Connor Sheehan's avatar Connor Sheehan
Browse files

Bug 1723985: coerce exceptions to `str` and then `pycompat.bytestr` before...

Bug 1723985: coerce exceptions to `str` and then `pycompat.bytestr` before displaying to screen r=mhentges

Adds exception formatting changes from version-control-tools to the
in-tree copy of `robustcheckout`.

Differential Revision: https://phabricator.services.mozilla.com/D124826
parent cd671440
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -495,23 +495,27 @@ def _docheckout(
            # Assume all SSL errors are due to the network, as Mercurial
            # should convert non-transport errors like cert validation failures
            # to error.Abort.
            ui.warn(b"ssl error: %s\n" % e)
            ui.warn(b"ssl error: %s\n" % pycompat.bytestr(str(e)))
            handlenetworkfailure()
            return True
        elif isinstance(e, urllibcompat.urlerr.urlerror):
            if isinstance(e.reason, socket.error):
                ui.warn(b"socket error: %s\n" % pycompat.bytestr(e.reason))
                ui.warn(b"socket error: %s\n" % pycompat.bytestr(str(e.reason)))
                handlenetworkfailure()
                return True
            else:
                ui.warn(
                    b"unhandled URLError; reason type: %s; value: %s\n"
                    % (e.reason.__class__.__name__, e.reason)
                    % (
                        pycompat.bytestr(e.reason.__class__.__name__),
                        pycompat.bytestr(str(e.reason)),
                    )
                )
        else:
            ui.warn(
                b"unhandled exception during network operation; type: %s; "
                b"value: %s\n" % (e.__class__.__name__, e)
                b"value: %s\n"
                % (pycompat.bytestr(e.__class__.__name__), pycompat.bytestr(str(e)))
            )

        return False