[PATCH 1 of 2] error: add ProgrammingError

Gábor STEFANIK Gabor.STEFANIK at nng.com
Tue Dec 13 11:52:31 EST 2016


>


--------------------------------------------------------------------------
This message, including its attachments, is confidential. For more information please read NNG's email policy here:
http://www.nng.com/emailpolicy/
By responding to this email you accept the email policy.


-----Original Message-----
> From: Mercurial-devel [mailto:mercurial-devel-bounces at mercurial-scm.org]
> On Behalf Of Jun Wu
> Sent: Tuesday, December 6, 2016 6:14 PM
> To: mercurial-devel at mercurial-scm.org
> Subject: [PATCH 1 of 2] error: add ProgrammingError
>
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1481036267 0
> #      Tue Dec 06 14:57:47 2016 +0000
> # Node ID 67bcd43e64ca03f486a817fccf38e83020b06793
> # Parent  2463b16bbd3710b619e0e948651db9948341f990
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 67bcd43e64ca
> error: add ProgrammingError
>
> We have requirement to express "this is clearly an error caused by the
> programmer". The code base uses RuntimeError for that in some places, not
> ideal. So let's add a formal exception for that.
>
> diff --git a/mercurial/error.py b/mercurial/error.py
> --- a/mercurial/error.py
> +++ b/mercurial/error.py
> @@ -169,4 +169,7 @@ class PushRaced(RuntimeError):
>      """An exception raised during unbundling that indicate a push race"""
>
> +class ProgrammingError(RuntimeError):

I would suggest InternalError, assuming it's not reserved by the Python
language, or used for something else already in Hg.
"ProgrammingError" could be interpreted as a programming error in Hg,
but also a programming error in tracked code. It's more of a stretch than
with "developer", but "internal" is still clearer than "programming".

See also: GCC's ICEs (but "in-SCM exception" is clunky IMO)

> +    """Raised if a developer has made some mistake"""
> +
>  # bundle2 related errors
>  class BundleValueError(ValueError):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list