Commit Graph

77 Commits

Author SHA1 Message Date
Yuya Nishihara
b772b7f536 error: move patch.PatchError so it can easily implement __bytes__ (API) 2017-09-03 16:45:33 +09:00
Yuya Nishihara
8840d7ead5 py3: implement __bytes__() on most of our exception classes
We store bytes in exc.args, which should be translated to a byte string
without encode/decode dance.

IOError subclasses are unchanged for now. We'll need to decide how our
IOErrors should be caught.
2017-06-01 22:43:24 +09:00
Pierre-Yves David
0b43826a5f obsolete: raise richer exception on unknown version
We raise a more precise subclass of Abort with details about the faulty
version.  This will be used to detect this case  and display some information
in debugbundle.
2017-05-25 16:50:23 +02:00
Pulkit Goyal
8c8779ddbb error: add a new exception named WdirUnsupported
This series intents to support wdir() predicate with different operators
like ~, ^.

Currently the storage class don't support wdir(). This exception is introduced
so that it can be raised from places where wdir() is passed and is not
supported and we can catch this where we want to support the predicate.
Also throwing an error at low level and catching at some higher level is better
than using if-else especially for perf.
2017-05-19 19:10:37 +05:30
Yuya Nishihara
1e7ba75af3 error: add hint to ProgrammingError
As the hint isn't shown by the default exception handler, we need to print
it manually. I've copied the "** " style from _exceptionwarning().
2017-05-14 15:41:27 +09:00
Gregory Szorc
6b50f59909 error: rename RichIOError to PeerTransportError
This is a more descriptive name. RichIOError was introduced just
hours ago, so it doesn't need to be marked as BC.
2017-04-16 11:12:37 -07:00
Gregory Szorc
4958a4d6ca httppeer: wrap HTTPResponse.read() globally
There were a handful of places in the code where HTTPResponse.read()
was called with no explicit error handling or with inconsistent
error handling. In order to eliminate this class of bug, we globally
swap out HTTPResponse.read() with a unified error handler.

I initially attempted to fix all call sites. However, after
going down that rabbit hole, I figured it was best to just change
read() to do what we want. This appears to be a worthwhile
change, as the tests demonstrate many of our uncaught exceptions
go away.

To better represent this class of failure, we introduce a new
error type. The main benefit over IOError is it can hold a hint.
I'm receptive to tweaking its name or inheritance.
2017-04-14 00:33:56 -07:00
Bryan O'Sullivan
84ac0ade7c stdio: add machinery to identify failed stdout/stderr writes
Mercurial currently fails to notice failures to write to stdout or
stderr. A correctly functioning command line tool should detect
this and exit with an error code.

To achieve this, we need a little extra plumbing, which we start
adding here.
2017-04-11 14:54:12 -07:00
Augie Fackler
67b9f85199 error: use r-string to properly pop hints from **kw
Fixes the hint mixin on Python 3.
2017-03-19 01:02:42 -04:00
Jun Wu
1d0e485ba1 error: make it clear that ProgrammingError is for mercurial developers
The word "developer" could refer to users - people using hg are likely to be
developers. Add adjectives to make it refer to mercurial developers only.
2016-12-12 08:01:52 +00:00
Jun Wu
d8c4533301 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.
2016-12-06 14:57:47 +00:00
Mads Kiilerich
38cb771268 spelling: fixes of non-dictionary words 2016-10-17 23:16:55 +02:00
Kostia Balytskyi
e27abece5f shelve: make unshelve be able to abort in any case 2016-07-13 16:16:18 +01:00
Yuya Nishihara
2e776c55f7 error: make hintable exceptions reject unknown keyword arguments (API)
Previously they would accept any typos of the hint keyword.
2016-07-11 21:40:02 +09:00
Yuya Nishihara
348d73cc98 error: make HintException a mix-in class not derived from BaseException (API)
HintException is unrelated to the hierarchy of errors. It is an implementation
detail whether a class inherits from HintException or not, a sort of "private
inheritance" in C++.

New Hint isn't an exception class, which prevents catching error by its type:

    try:
        dosomething()
    except error.Hint:
        pass

Unfortunately, this passes on PyPy 5.3.1, but not on Python 2, and raises more
detailed TypeError on Python 3.
2016-07-09 14:28:30 +09:00
Pierre-Yves David
4975fa6f10 destutil: add more precise error classes for destmerge
Having exception classes more precise than 'Abort' will allow us to properly
catch "nothing to rebase" situations when we will be using 'destmerge' in
rebase.
2016-02-09 23:30:41 +00:00
timeless
7ff607f2d6 error: make InterventionRequired take a hint 2015-12-23 08:52:52 +00:00
timeless
da2a72be71 error: make ParseError inherit from HintException 2015-12-23 17:39:32 +00:00
timeless
5d88e6719b error: refactor OutOfBandError to inherit from HintException 2015-12-23 17:38:24 +00:00
Siddharth Agarwal
a13e973d08 error: add a structured exception for unsupported merge records
We're going to use this in summary to print a better error message.
2015-11-17 14:10:12 -08:00
Siddharth Agarwal
6e6f3927e3 error: add structured exception for EOF at prompt
We'll catch this exception for promptchoice queries to provide better error
handling.
2015-11-10 00:46:45 -08:00
Augie Fackler
6caeb62341 error: remove superfluous pass statements 2015-10-15 09:52:32 -04:00
Siddharth Agarwal
d01bcde561 hook: raise a separate exception for when loading a hook fails
For easier catching.
2015-10-12 18:49:23 -07:00
Pierre-Yves David
e4483e415c update: introduce a 'UpdateAbort' exception
The 'postincoming' function used by 'hg pull --update' and 'hg unbundle' is
catching 'Abort' exceptions to intercept failed update. This feel a bit too
wide to me, so I'm introducing a more precise exception to specify update
destination issues.
2015-10-05 04:26:26 -07:00
Gregory Szorc
c55df1f741 exchange: refactor bundle specification parsing
The old code was tailored to `hg bundle` usage and not appropriate for
use as a general API, which clone bundles will require. The code has
been rewritten to make it more generally suitable.

We introduce dedicated error types to represent invalid and unsupported
bundle specifications. The reason we need dedicated error types (rather
than error.Abort) is because clone bundles will want to catch these
exception as part of filtering entries. We don't want to swallow
error.Abort on principle.
2015-10-13 10:57:54 -07:00
Siddharth Agarwal
07b2481d7b error: make lock inheritance contract violations a subclass of RuntimeError
This is more appropriate, per Pierre-Yves David.
2015-09-25 12:56:05 -07:00
Pierre-Yves David
485efcee1f bundle2: allow to specify unsupported value on error
A client may support an argument but not some of its values (eg: coming
"compression" parameters). We allow this case to be carried in the
exception.
2015-09-23 11:55:27 -07:00
Pierre-Yves David
2aa8064fde bundle2: rename error exception class for unsupported feature
The original name explicitly mention "Part", however it is also used outside of
parts related feature. We rename from 'UnsupportedPartError' to
'BundleUnknownFeatureError' to fix this.
2015-09-23 11:44:52 -07:00
Siddharth Agarwal
9bb5535bd0 error: add an exception to indicate lock inheritance API contract violations 2015-09-24 10:53:16 -07:00
Gregory Szorc
62db11fad0 error: use absolute_import 2015-08-08 19:09:09 -07:00
Pierre-Yves David
4386f8310a bundle2: introduce a PushkeyFail error to abort unbundle on pushkey error
The pushkey code is generic and the server side has little context on what the
client is trying to achieve. Generating interesting error messages server side
would be challenging. Instead we introduce a dedicated exception that carries more
data. In particular, it carries the id of the part which failed that will allow
clients to display custom error messages depending on the part intent.

The processing and transfer-over-the-wire of this exception is to be implemented
in coming changesets.
2015-05-27 23:48:54 -07:00
Jordi Gutiérrez Hermoso
64f6058e68 error: derive RevlogError from HintException instead of Exception
This will allow us to now pass hints into this exception.
2015-05-21 16:20:34 -04:00
Jordi Gutiérrez Hermoso
4076b33bc3 error: refactor common hint-pattern into a common base class
I'm about to make another exception class require hints, so third
strike and you refactor.
2015-05-21 16:28:06 -04:00
Pierre-Yves David
8e64cd3aeb error: allow a 'hint' to OutOfBandError
This will be useful when changing the behavior of OutOfBandError for ssh in the
next changeset.
2015-05-20 18:17:40 -05:00
Augie Fackler
b35328ab65 error: add a new UnknownIdentifier error type
This will be used by the revset and fileset code to communicate more
specific errors to higher levels so that we might be able to offer
suggestions about what function might have been similar.
2015-01-26 14:31:01 -05:00
Mike Edgar
b4a5dfbe4d changegroup: emit full-replacement deltas if either revision is censored
To ensure that exchanged deltas in the presence of censored revisions can
always be applied to the recipient repository, the deltas must replace the
entire base text. To make this restriction reasonably enforceable, the delta
must do so with a single patch operation.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-01-21 22:09:32 -05:00
Siddharth Agarwal
f7ee37c26e error.LookupError: rename 'message' property to something else
At least some installs of Python 2.6+ complain with:

    mercurial/error.py:26: DeprecationWarning: BaseException.message has been
        deprecated as of Python 2.6

This patch renames the property away from 'message' so that Python no longer
complains.
2015-02-18 16:45:16 -08:00
Mike Edgar
9635f8c5b0 revlog: in addgroup, reject ill-formed deltas based on censored nodes
To ensure interoperability when clones disagree about which file nodes are
censored, a restriction is made on deltas based on censored nodes. Any such
delta must replace the full text of the base in a single patch.

If the recipient of a delta considers the base to be censored and the delta
is not in the expected form, the recipient must reject it, as it can't know
if the source has also censored the base.

For background and broader design of the censorship feature, see:
http://mercurial.selenic.com/wiki/CensorPlan
2015-02-06 00:55:29 +00:00
Augie Fackler
e17e818366 error: update docstring on ParseError
It's now used by revsets and filesets.
2015-01-26 14:30:12 -05:00
Martin von Zweigbergk
20c7bd86fa error: store filename and message on LookupError for later
It may be useful to be able to get to the failed path and the
underlying error message when catching a LookupError, so let's make
them accessible.
2015-02-04 13:57:35 -08:00
Pierre-Yves David
6cf24b99de hook: raise a more specialized HookAbort exception when a hook fails
We need to gracefully handle some aborts for pushkey, especially
because it leads to a user-facing crash over the wireprotocols. So we
need a more specialized exception to catch.
2014-11-29 19:13:35 -08:00
Pierre-Yves David
5cf4921b01 repoview: add a FilteredRepoLookupError
This exception is a more precise RepoLookupError that will allow us to issue
a special message when we end up accessing a filtered revision.
2014-10-16 02:06:12 -07:00
Pierre-Yves David
37d7d2958f repoview: add a FilteredLookupError class
This exception is a more precise LookupError that will allow us to
issue a special message when we end up accessing a filtered revision.
2014-10-16 02:05:06 -07:00
Pierre-Yves David
ea3e835124 repoview: add a FilteredIndexError class
This exception is a more precise IndexError that will allow us to
issue a special message when we end up accessing a filtered revision.
2014-10-15 17:02:44 -07:00
Pierre-Yves David
2ecc46cd04 bundle2: add an UnsupportedPartError
We need the BundleValueError for format errors not related to part support. So
we add a specific class for part-support errors.
2014-10-15 03:22:47 -07:00
Mike Edgar
e100ea2d6a error: add CensoredNodeError, will be thrown when content deliberately erased
This change introduces the error plus a corresponding catch in dispatch, to
provide localized error messages.

The verb "censor" is used in this commit and all following to refer to erasing
the content of a revlog revision (filelog, for now) without recalculating node
IDs, leaving that revision invalid. Further work must be done to safely share
such revision data with compliant clients.

I find the analogy to censorship straightforward; for less politically
charged options, consider "erase", "excise", "expunge", or "blackhole".
2014-09-03 15:59:03 -04:00
Mike Edgar
be835fe233 error: use docstrings, not bare strings, for error classes 2014-08-30 12:22:20 +02:00
Brendan Cully
84c737c817 error: restore python 2.4 compatibility for BundleValueError
Under python 2.4, this:
    super(BundleValueError, self).__init__(msg)
raises this:
    TypeError: super() argument 1 must be type, not classobj
2014-06-10 17:00:31 -07:00
Pierre-Yves David
ee9ac67c31 bundle2: support None parttype in BundleValueError
This will be used for errors at the stream level.
2014-05-28 16:46:58 -07:00
Pierre-Yves David
e625997ab5 bundle2: introduce a `params` attribute to BundleValueError
We'll first use it for unsupported mandatory parameters on parts.
2014-05-28 15:53:34 -07:00