Skip to content
Snippets Groups Projects
Select Git revision
  • 71ea58c21a0696f2bf5a699ba9fa4ca6dbb46395
  • master default protected
  • dev
  • appimage
  • fix_gitlab
  • fixappveyor
  • gitlab
  • fix_ci
  • fix_dbus_error
  • fix_ci_osx
  • sakia020
  • fix_travis#1105
  • feature/backend
  • check_uniq_node_by_endpoints
  • qt5.7
  • feature/agent_architecture
  • translations
  • pyqt5.6
  • qtwebengine
  • pyinstaller
  • landscape
  • 0.53.2
  • 0.53.1
  • 0.53.0
  • 0.52.0
  • 0.51.1
  • 0.51.0
  • 0.50.5
  • 0.50.4
  • 0.50.3
  • 0.50.2
  • 0.50.1
  • 0.50.0
  • 0.33.0rc7
  • 0.33.0rc6
  • 0.33.0rc5
  • 0.33.0rc4
  • 0.33.0rc3
  • 0.33.0rc2
  • 0.33.0rc1
  • 0.32.10post1
41 results

exceptions.py

Blame
  • exceptions.py 4.18 KiB
    '''
    Created on 9 févr. 2014
    
    @author: inso
    '''
    
    
    class Error(Exception):
    
        def __init__(self, message):
            '''
            Constructor
            '''
            self.message = "Error : " + message
    
        def __str__(self):
            return self.message
    
    
    class NotMemberOfCommunityError(Error):
    
        '''
        Exception raised when adding a community the account is not a member of
        '''
    
        def __init__(self, account, community):
            '''
            Constructor
            '''
            super() \
                .__init__(account + " is not a member of " + community)
    
    
    class PersonNotFoundError(Error):
    
        '''
        Exception raised when looking for a person in a community
        who isnt present in key list
        '''
    
        def __init__(self, value, community):
            '''
            Constructor
            '''
            super() .__init__(
                "Person looked by {0} in {1} not found ".format(value, community))
    
    
    class MembershipNotFoundError(Error):
    
        '''
        Exception raised when looking for a person in a community
        who isnt present in key list
        '''
    
        def __init__(self, value, community):
            '''
            Constructor
            '''
            super() .__init__(
                "Membership searched by " +
                value +
                " in " +
                community +
                " not found ")
    
    
    class AlgorithmNotImplemented(Error):
    
        '''
        Exception raised when a coin uses an algorithm not known
        '''
    
        def __init__(self, algo_name):
            '''
            Constructor
            '''
            super() \
                .__init__("Algorithm " + algo_name + " not implemented.")
    
    
    class KeyAlreadyUsed(Error):
    
        '''
        Exception raised trying to add an account using
        a key already used for another account.
        '''
    
        def __init__(self, new_account, keyid, found_account):
            '''
            Constructor
            '''
            super() .__init__(
    """Cannot add account {0} :
    the key {1} is already used by {2}""".format(new_account,
                                                 keyid,
                                                 found_account)
                )
    
    
    class NameAlreadyExists(Error):
    
        '''
        Exception raised trying to add an account using
        a key already used for another account.
        '''
    
        def __init__(self, account_name):
            '''
            Constructor
            '''
            super() .__init__(
                "Cannot add account " +
                account_name +
                " the name already exists")
    
    
    class BadAccountFile(Error):
    
        '''
        Exception raised trying to add an account using
        a key already used for another account.
        '''
    
        def __init__(self, path):
            '''
            Constructor
            '''
            super() .__init__(
                "File " + path + " is not an account file")
    
    
    class NotEnoughMoneyError(Error):
    
        '''
        Exception raised trying to add an account using
        a key already used for another account.
        '''
    
        def __init__(self, available, currency, nb_inputs, requested):
            '''
            Constructor
            '''
            super() .__init__(
                "Only {0} {1} available in {2} sources, needs {3}"
                .format(available,
                        currency,
                        nb_inputs,
                        requested))
    
    
    class NoPeerAvailable(Error):
        '''
        Exception raised when a community doesn't have any
        peer available.
        '''
        def __init__(self, currency, peers):
            '''
            Constructor
            '''
            super() .__init__(
                "No peer answered in {0} community ({1} peers available)"
                .format(currency, peers))
    
    
    class InvalidNodeCurrency(Error):
        '''
        Exception raised when a node doesn't use the intended currency
        '''
        def __init__(self, currency, node_currency):
            '''
            Constructor
            '''
            super() .__init__(
                "Node is working for {0} currency, but should be {1}"
                .format(node_currency, currency))
    
    
    class ContactAlreadyExists(Error):
        '''
        Exception raised when a community doesn't have any
        peer available.
        '''
        def __init__(self, new_contact, already_contact):
            '''
            Constructor
            '''
            super() .__init__(
                "Cannot add {0}, he/she has the same pubkey as {1} contact"
                .format(new_contact, already_contact))