magic-wormhole/src/wormhole/errors.py

127 lines
3.5 KiB
Python
Raw Normal View History

from __future__ import unicode_literals
2018-04-21 07:30:08 +00:00
class WormholeError(Exception):
"""Parent class for all wormhole-related errors"""
2018-04-21 07:30:08 +00:00
2017-05-24 00:36:34 +00:00
class UnsendableFileError(Exception):
"""
A file you wanted to send couldn't be read, maybe because it's not
a file, or because it's a symlink that points to something
that doesn't exist.
To ignore this kind of error, you can run wormhole with the
--ignore-unsendable-files flag.
"""
2018-04-21 07:30:08 +00:00
class ServerError(WormholeError):
"""The relay server complained about something we did."""
2018-04-21 07:30:08 +00:00
class ServerConnectionError(WormholeError):
"""We had a problem connecting to the relay server:"""
2018-04-21 07:30:08 +00:00
def __init__(self, url, reason):
self.url = url
self.reason = reason
2018-04-21 07:30:08 +00:00
def __str__(self):
return str(self.reason)
2018-04-21 07:30:08 +00:00
class Timeout(WormholeError):
pass
2018-04-21 07:30:08 +00:00
class WelcomeError(WormholeError):
2016-05-26 22:36:44 +00:00
"""
The relay server told us to signal an error, probably because our version
is too old to possibly work. The server said:"""
pass
2016-05-23 07:14:39 +00:00
2018-04-21 07:30:08 +00:00
class LonelyError(WormholeError):
"""wormhole.close() was called before the peer connection could be
established"""
2018-04-21 07:30:08 +00:00
class WrongPasswordError(WormholeError):
"""
Key confirmation failed. Either you or your correspondent typed the code
wrong, or a would-be man-in-the-middle attacker guessed incorrectly. You
could try again, giving both your correspondent and the attacker another
chance.
"""
# or the data blob was corrupted, and that's why decrypt failed
2016-05-26 22:36:44 +00:00
pass
2018-04-21 07:30:08 +00:00
class KeyFormatError(WormholeError):
2016-06-02 21:07:27 +00:00
"""
The key you entered contains spaces or was missing a dash. Magic-wormhole
expects the numerical nameplate and the code words to be separated by
dashes. Please reenter the key you were given separating the words with
dashes.
2016-06-02 21:07:27 +00:00
"""
2018-04-21 07:30:08 +00:00
class ReflectionAttack(WormholeError):
"""An attacker (or bug) reflected our outgoing message back to us."""
2018-04-21 07:30:08 +00:00
class InternalError(WormholeError):
"""The programmer did something wrong."""
2018-04-21 07:30:08 +00:00
class TransferError(WormholeError):
"""Something bad happened and the transfer failed."""
2018-04-21 07:30:08 +00:00
class NoTorError(WormholeError):
"""--tor was requested, but 'txtorcon' is not installed."""
2017-03-04 09:55:42 +00:00
2018-04-21 07:30:08 +00:00
2017-03-04 09:55:42 +00:00
class NoKeyError(WormholeError):
"""w.derive_key() was called before got_verifier() fired"""
2018-04-21 07:30:08 +00:00
2017-03-08 07:45:11 +00:00
class OnlyOneCodeError(WormholeError):
"""Only one w.generate_code/w.set_code/w.input_code may be called"""
2017-03-08 07:45:11 +00:00
2018-04-21 07:30:08 +00:00
class MustChooseNameplateFirstError(WormholeError):
"""The InputHelper was asked to do get_word_completions() or
choose_words() before the nameplate was chosen."""
2018-04-21 07:30:08 +00:00
class AlreadyChoseNameplateError(WormholeError):
"""The InputHelper was asked to do get_nameplate_completions() after
choose_nameplate() was called, or choose_nameplate() was called a second
time."""
2018-04-21 07:30:08 +00:00
class AlreadyChoseWordsError(WormholeError):
"""The InputHelper was asked to do get_word_completions() after
choose_words() was called, or choose_words() was called a second time."""
2018-04-21 07:30:08 +00:00
class AlreadyInputNameplateError(WormholeError):
"""The CodeInputter was asked to do completion on a nameplate, when we
had already committed to a different one."""
2018-04-21 07:30:08 +00:00
class WormholeClosed(Exception):
"""Deferred-returning API calls errback with WormholeClosed if the
wormhole was already closed, or if it closes before a real result can be
obtained."""
2018-04-21 07:30:08 +00:00
2017-03-19 22:09:26 +00:00
class _UnknownPhaseError(Exception):
"""internal exception type, for tests."""
2018-04-21 07:30:08 +00:00
2017-03-19 22:09:26 +00:00
class _UnknownMessageTypeError(Exception):
"""internal exception type, for tests."""