Patchwork [1,of,2] error: add ProgrammingError

login
register
mail settings
Submitter Jun Wu
Date Dec. 6, 2016, 5:13 p.m.
Message ID <67bcd43e64ca03f486a8.1481044435@x1c>
Download mbox | patch
Permalink /patch/17840/
State Accepted
Headers show

Comments

Jun Wu - Dec. 6, 2016, 5:13 p.m.
# HG changeset patch
# User Jun Wu <quark@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.
timeless - Dec. 12, 2016, 4:24 a.m.
Jun Wu wrote:
> +class ProgrammingError(RuntimeError):
> +    """Raised if a developer has made some mistake"""

I object to "developer"

you probably mean "mercurial (core or extension) developer", not
"generic developer".
Gábor Stefanik - Dec. 13, 2016, 4:52 p.m.
>



--------------------------------------------------------------------------
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@mercurial-scm.org]

> On Behalf Of Jun Wu

> Sent: Tuesday, December 6, 2016 6:14 PM

> To: mercurial-devel@mercurial-scm.org

> Subject: [PATCH 1 of 2] error: add ProgrammingError

>

> # HG changeset patch

> # User Jun Wu <quark@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@mercurial-scm.org

> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Gábor Stefanik - Dec. 13, 2016, 4:58 p.m.
>



--------------------------------------------------------------------------
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@mercurial-scm.org]

> On Behalf Of Gábor STEFANIK

> Sent: Tuesday, December 13, 2016 5:53 PM

> To: Jun Wu <quark@fb.com>; mercurial-devel@mercurial-scm.org

> Subject: RE: [PATCH 1 of 2] error: add ProgrammingError

>

> >

>

>

> --------------------------------------------------------------------------

> 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@mercurial-scm.org]

> > On Behalf Of Jun Wu

> > Sent: Tuesday, December 6, 2016 6:14 PM

> > To: mercurial-devel@mercurial-scm.org

> > Subject: [PATCH 1 of 2] error: add ProgrammingError

> >

> > # HG changeset patch

> > # User Jun Wu <quark@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)


Looks like I was wrong - ICE apparently stands for "internal compiler error", not "in-compiler exception".
So, InternalError is in agreement with GCC's nomenclature.

>

> > +    """Raised if a developer has made some mistake"""

> > +

> >  # bundle2 related errors

> >  class BundleValueError(ValueError):

> > _______________________________________________

> > Mercurial-devel mailing list

> > Mercurial-devel@mercurial-scm.org

> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

> _______________________________________________

> Mercurial-devel mailing list

> Mercurial-devel@mercurial-scm.org

> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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):
+    """Raised if a developer has made some mistake"""
+
 # bundle2 related errors
 class BundleValueError(ValueError):