Skip to content

Commit

Permalink
Ucoin Errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Mar 19, 2016
1 parent 70b0367 commit 9bf9b60
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ucoinpy/api/bma/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
logger = logging.getLogger("ucoin")


from .api import API, ConnectionHandler, UcoinError
from .api import API, ConnectionHandler
from . import network, blockchain, tx, wot, node, ud, ws
11 changes: 2 additions & 9 deletions ucoinpy/api/bma/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@

import aiohttp, json, logging, jsonschema

logger = logging.getLogger("ucoin")

from ..errors import UcoinError

class UcoinError(Exception):
"""
UCoin error
"""
def __init__(self, data):
super().__init__("Error code {0} - {1}".format(data["ucode"], data["message"]))
self.error = data
logger = logging.getLogger("ucoin")


class ConnectionHandler(object):
Expand Down
45 changes: 45 additions & 0 deletions ucoinpy/api/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

class UcoinError(Exception):
"""
UCoin error
"""
def __init__(self, data):
super().__init__("Error code {0} - {1}".format(data["ucode"], data["message"]))
self.ucode = data["ucode"]
self.message = data["message"]

UNKNOWN = 1001
UNHANDLED = 1002
SIGNATURE_DOES_NOT_MATCH = 1003
ALREADY_UP_TO_DATE = 1004
WRONG_DOCUMENT = 1005

HTTP_PARAM_PUBKEY_REQUIRED = 1101
HTTP_PARAM_IDENTITY_REQUIRED = 1102
HTTP_PARAM_PEER_REQUIRED = 1103
HTTP_PARAM_BLOCK_REQUIRED = 1104
HTTP_PARAM_MEMBERSHIP_REQUIRED = 1105
HTTP_PARAM_TX_REQUIRED = 1106
HTTP_PARAM_SIG_REQUIRED = 1107
HTTP_PARAM_CERT_REQUIRED = 1108
HTTP_PARAM_REVOCATION_REQUIRED = 1109
HTTP_PARAM_CONF_REQUIRED = 1110

NO_MATCHING_IDENTITY = 2001
UID_ALREADY_USED = 2002
PUBKEY_ALREADY_USED = 2003
NO_MEMBER_MATCHING_PUB_OR_UID = 2004
SELF_PEER_NOT_FOUND = 2005
WRONG_SIGNATURE_MEMBERSHIP = 2006
ALREADY_RECEIVED_MEMBERSHIP = 2007
MEMBERSHIP_A_NON_MEMBER_CANNOT_LEAVE = 2008
NOT_A_MEMBER = 2009
NO_CURRENT_BLOCK = 2010
BLOCK_NOT_FOUND = 2011
PEER_NOT_FOUND = 2012
WRONG_UNLOCKER = 2013
LOCKTIME_PREVENT = 2014
SOURCE_ALREADY_CONSUMED = 2015
WRONG_AMOUNTS = 2016
WRONG_OUTPUT_BASE = 2017
CANNOT_ROOT_BLOCK_NO_MEMBERS = 2018

0 comments on commit 9bf9b60

Please sign in to comment.