[PATCH RFC] scmutil: add a simple key-value file helper

Jun Wu quark at fb.com
Mon Dec 5 17:51:28 EST 2016


Excerpts from Augie Fackler's message of 2016-12-05 17:07:47 -0500:
> 
> > On Dec 5, 2016, at 16:54, Jun Wu <quark at fb.com> wrote:
> > 
> >> +                e = _("Invalid value in a simple key-value file")
> >> +                raise self.InvalidValueInFileException(e)
> > 
> > These sound like a programmer error. Maybe just raise RuntimeError.
> 
> I'm not comfortable with that, FYI. RuntimeError IMO should be reserved for errors in the Python runtime itself, not run-time errors caused by programmer error.

>From what I have learn from the code base. We use RuntimeError for
programmer errors. Seems to be the most "popular" solution.

  merge.py
  317:            raise RuntimeError("localctx accessed but self._local isn't set")
  323:            raise RuntimeError("otherctx accessed but self._other isn't set")
  
  context.py
  2011:           raise RuntimeError('can\'t reuse the manifest: '
  2014:           raise RuntimeError('can\'t reuse the manifest: '

  localrepo.py
  1019:           raise RuntimeError('programming error: transaction requires '

There are some subclasses of RuntimeError though:

  bundle2.py
  298:class TransactionUnavailable(RuntimeError):
  856:                raise RuntimeError('duplicated params: %s' % pname)
  909:            raise RuntimeError('part can only be consumed once')
  1078:        raise RuntimeError('no repo access from stream interruption')

  error.py
  149:class LockInheritanceContractViolation(RuntimeError):
  168:class PushRaced(RuntimeError):
  198:class ReadOnlyPartError(RuntimeError):


More information about the Mercurial-devel mailing list