[PATCH 1 of 2 STABLE] run: catch parse error of config file by ConfigError

8 vues
Accéder directement au premier message non lu

Yuya Nishihara

non lue,
29 sept. 2022, 23:54:3729/09/2022
à thg...@googlegroups.com,Matt Harbison
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1664509068 -32400
# Fri Sep 30 12:37:48 2022 +0900
# Branch stable
# Node ID a4093640631fc5c0e0103aefe2058adba9b1b0f1
# Parent b619f172c9da3520415adf9738d4ada63f7127f5
run: catch parse error of config file by ConfigError

ParseError was replaced with ConfigError at hg 9dc1351d0b5f "errors: raise
ConfigError on failure to parse config file."

diff --git a/tortoisehg/hgqt/run.py b/tortoisehg/hgqt/run.py
--- a/tortoisehg/hgqt/run.py
+++ b/tortoisehg/hgqt/run.py
@@ -137,7 +137,7 @@ def dispatch(args, u=None):
if b'--debugger' in args:
pdb.set_trace()
return _runcatch(u, args)
- except error.ParseError as e:
+ except error.ConfigError as e:
qtapp.earlyExceptionMsgBox(e)
except SystemExit as e:
return e.code

Yuya Nishihara

non lue,
29 sept. 2022, 23:54:3929/09/2022
à thg...@googlegroups.com,Matt Harbison
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1664509563 -32400
# Fri Sep 30 12:46:03 2022 +0900
# Branch stable
# Node ID 7b9d45a26179fb9541306fdd1ca87ffd3daa411b
# Parent a4093640631fc5c0e0103aefe2058adba9b1b0f1
bugreport: retranslate ConfigError containing location as ParseError

The '#fix' action doesn't work in that case since the ui can't be
instantiated.

diff --git a/tortoisehg/hgqt/qtapp.py b/tortoisehg/hgqt/qtapp.py
--- a/tortoisehg/hgqt/qtapp.py
+++ b/tortoisehg/hgqt/qtapp.py
@@ -112,9 +112,14 @@ def earlyExceptionMsgBox(e):
'values': [hglib.tounicode(str(e))],
'error': traceback.format_exc(),
'nofork': True}
- if isinstance(e, error.ParseError) and e.location:
+ errstring = _recoverableexc[e.__class__]
+ if isinstance(e, error.ConfigError) and e.location:
+ # If ConfigError contained a location, the config file couldn't be
+ # parsed at all. So '#edit:<location>' is the only way to fix.
+ errstring = _recoverableexc[error.ParseError]
opts['values'] += [hglib.tounicode(e.location)]
- errstring = _recoverableexc[e.__class__]
+ elif isinstance(e, error.ParseError) and e.location:
+ opts['values'] += [hglib.tounicode(e.location)]
if not QApplication.instance():
main = QApplication(sys.argv)
dlg = bugreport.ExceptionMsgBox(hglib.tounicode(str(e)), errstring, opts)

Matt Harbison

non lue,
30 sept. 2022, 12:08:3030/09/2022
à TortoiseHg Developers
On Thursday, September 29, 2022 at 11:54:39 PM UTC-4 Yuya Nishihara wrote:
# HG changeset patch
# User Yuya Nishihara <yu...@tcha.org>
# Date 1664509563 -32400
# Fri Sep 30 12:46:03 2022 +0900
# Branch stable
# Node ID 7b9d45a26179fb9541306fdd1ca87ffd3daa411b
# Parent a4093640631fc5c0e0103aefe2058adba9b1b0f1
bugreport: retranslate ConfigError containing location as ParseError

LGTM, thanks.

The bugreport stacktrace still doesn't show the detailed info in the stacktrace, but it does show it in the initial popup box with the #edit action, and I guess that's the best we can do if Error.__str__() doesn't produce that info.

 

Yuya Nishihara

non lue,
1 oct. 2022, 05:58:0701/10/2022
à 'Matt Harbison' via TortoiseHg Developers
On Fri, 30 Sep 2022 09:08:30 -0700 (PDT), 'Matt Harbison' via TortoiseHg Developers wrote:
> On Thursday, September 29, 2022 at 11:54:39 PM UTC-4 Yuya Nishihara wrote:
>
> > # HG changeset patch
> > # User Yuya Nishihara <yu...@tcha.org>
> > # Date 1664509563 -32400
> > # Fri Sep 30 12:46:03 2022 +0900
> > # Branch stable
> > # Node ID 7b9d45a26179fb9541306fdd1ca87ffd3daa411b
> > # Parent a4093640631fc5c0e0103aefe2058adba9b1b0f1
> > bugreport: retranslate ConfigError containing location as ParseError
> >
>
> LGTM, thanks.

Pushed.

> The bugreport stacktrace still doesn't show the detailed info in the
> stacktrace, but it does show it in the initial popup box with the #edit
> action, and I guess that's the best we can do if Error.__str__() doesn't
> produce that info.

Yep. BugReport dialog isn't designed for known user errors.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message