Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/chgserver.py @ 47300:33c0c25d0b0f
errors: let each Abort subclass define its error code
It's more flexible to have the error codes defined on the error types
themselves. That way extensions can easily set their own exit code. It
also means that we can reduce a bit of duplication betwen
`scmutil.callcatch()` and `chgserver.chgcmdserver.validate()`.
Differential Revision: https://phab.mercurial-scm.org/D10735
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 18 May 2021 17:15:49 -0700 |
parents | 6383bb86b700 |
children | 7a769ac49637 |
comparison
equal
deleted
inserted
replaced
47299:16b48ebf656e | 47300:33c0c25d0b0f |
---|---|
514 self.ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst)) | 514 self.ui.error(_(b"abort: %s\n") % stringutil.forcebytestr(inst)) |
515 if inst.hint: | 515 if inst.hint: |
516 self.ui.error(_(b"(%s)\n") % inst.hint) | 516 self.ui.error(_(b"(%s)\n") % inst.hint) |
517 errorraised = True | 517 errorraised = True |
518 except error.Abort as inst: | 518 except error.Abort as inst: |
519 if isinstance(inst, error.InputError): | 519 if inst.detailed_exit_code is not None: |
520 detailed_exit_code = 10 | 520 detailed_exit_code = inst.detailed_exit_code |
521 elif isinstance(inst, error.ConfigError): | |
522 detailed_exit_code = 30 | |
523 self.ui.error(inst.format()) | 521 self.ui.error(inst.format()) |
524 errorraised = True | 522 errorraised = True |
525 | 523 |
526 if errorraised: | 524 if errorraised: |
527 self.ui.flush() | 525 self.ui.flush() |