From d5b51bcf9ef9aa4fab9b175d7ba9bea5e301500f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 10 Jun 2019 23:33:36 +0300 Subject: [PATCH] Use CatchableError --- libp2p/base32.nim | 2 +- libp2p/base58.nim | 2 +- libp2p/base64.nim | 2 +- libp2p/cid.nim | 2 +- libp2p/crypto/crypto.nim | 4 ++-- libp2p/crypto/ecnist.nim | 4 ++-- libp2p/crypto/ed25519/ed25519.nim | 2 +- libp2p/crypto/rsa.nim | 10 +++++----- libp2p/daemon/daemonapi.nim | 4 ++-- libp2p/multiaddress.nim | 2 +- libp2p/multibase.nim | 2 +- libp2p/multicodec.nim | 2 +- libp2p/multihash.nim | 2 +- libp2p/peer.nim | 2 +- libp2p/varint.nim | 2 +- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libp2p/base32.nim b/libp2p/base32.nim index e48f12d..fc36156 100644 --- a/libp2p/base32.nim +++ b/libp2p/base32.nim @@ -48,7 +48,7 @@ type Base32Types* = Base32NoPadTypes | Base32PadTypes ## Supported types - Base32Error* = object of Exception + Base32Error* = object of CatchableError ## Base32 specific exception type proc newAlphabet32*(s: string): Base32Alphabet = diff --git a/libp2p/base58.nim b/libp2p/base58.nim index 6b0851b..34fcce1 100644 --- a/libp2p/base58.nim +++ b/libp2p/base58.nim @@ -30,7 +30,7 @@ type Base58C* = BTCBase58 | FLCBase58 ## Supported types - Base58Error* = object of Exception + Base58Error* = object of CatchableError ## Base58 specific exception type proc newAlphabet58*(s: string): Base58Alphabet = diff --git a/libp2p/base64.nim b/libp2p/base64.nim index e3094f2..5d6889e 100644 --- a/libp2p/base64.nim +++ b/libp2p/base64.nim @@ -36,7 +36,7 @@ type Base64Types* = Base64 | Base64Pad | Base64Url | Base64UrlPad ## All types - Base64Error* = object of Exception + Base64Error* = object of CatchableError ## Base64 specific exception type proc newAlphabet64*(s: string): Base64Alphabet = diff --git a/libp2p/cid.nim b/libp2p/cid.nim index 93c88a4..2296846 100644 --- a/libp2p/cid.nim +++ b/libp2p/cid.nim @@ -24,7 +24,7 @@ type hpos*: int data*: VBuffer - CidError* = object of Exception + CidError* = object of CatchableError const ContentIdsList = [ diff --git a/libp2p/crypto/crypto.nim b/libp2p/crypto/crypto.nim index 118e3fe..c136c69 100644 --- a/libp2p/crypto/crypto.nim +++ b/libp2p/crypto/crypto.nim @@ -74,8 +74,8 @@ type Signature* = object data*: seq[byte] - P2pKeyError* = object of Exception - P2pSigError* = object of Exception + P2pKeyError* = object of CatchableError + P2pSigError* = object of CatchableError const SupportedSchemes* = {RSA, Ed25519, ECDSA} diff --git a/libp2p/crypto/ecnist.nim b/libp2p/crypto/ecnist.nim index 52cedc8..81ab34a 100644 --- a/libp2p/crypto/ecnist.nim +++ b/libp2p/crypto/ecnist.nim @@ -56,11 +56,11 @@ type EcPKI* = EcPrivateKey | EcPublicKey | EcSignature - EcError* = object of Exception + EcError* = object of CatchableError EcKeyIncorrectError* = object of EcError EcRngError* = object of EcError EcPublicKeyError* = object of EcError - EcSignatureError = object of EcError + EcSignatureError* = object of EcError const EcSupportedCurvesCint* = {cint(Secp256r1), cint(Secp384r1), cint(Secp521r1)} diff --git a/libp2p/crypto/ed25519/ed25519.nim b/libp2p/crypto/ed25519/ed25519.nim index 280cf07..5371d79 100644 --- a/libp2p/crypto/ed25519/ed25519.nim +++ b/libp2p/crypto/ed25519/ed25519.nim @@ -38,7 +38,7 @@ type seckey*: EdPrivateKey pubkey*: EdPublicKey - EdError* = object of Exception + EdError* = object of CatchableError EdRngError* = object of EdError EdIncorrectError* = object of EdError diff --git a/libp2p/crypto/rsa.nim b/libp2p/crypto/rsa.nim index 8f32b5f..0b0ba95 100644 --- a/libp2p/crypto/rsa.nim +++ b/libp2p/crypto/rsa.nim @@ -70,11 +70,11 @@ type RsaPKI* = RsaPrivateKey | RsaPublicKey | RsaSignature RsaKP* = RsaPrivateKey | RsaKeyPair - RsaError = object of Exception - RsaRngError = object of RsaError - RsaGenError = object of RsaError - RsaKeyIncorrectError = object of RsaError - RsaSignatureError = object of RsaError + RsaError* = object of CatchableError + RsaRngError* = object of RsaError + RsaGenError* = object of RsaError + RsaKeyIncorrectError* = object of RsaError + RsaSignatureError* = object of RsaError template getStart(bs, os, ls: untyped): untyped = let p = cast[uint](os) diff --git a/libp2p/daemon/daemonapi.nim b/libp2p/daemon/daemonapi.nim index 629460a..38886d4 100644 --- a/libp2p/daemon/daemonapi.nim +++ b/libp2p/daemon/daemonapi.nim @@ -146,8 +146,8 @@ type ticket: PubsubTicket, message: PubSubMessage): Future[bool] {.gcsafe.} - DaemonRemoteError* = object of Exception - DaemonLocalError* = object of Exception + DaemonRemoteError* = object of CatchableError + DaemonLocalError* = object of CatchableError var daemonsCount {.threadvar.}: int diff --git a/libp2p/multiaddress.nim b/libp2p/multiaddress.nim index 96e9211..5960a40 100644 --- a/libp2p/multiaddress.nim +++ b/libp2p/multiaddress.nim @@ -39,7 +39,7 @@ type flag*: bool rem*: seq[MultiCodec] - MultiAddressError* = object of Exception + MultiAddressError* = object of CatchableError proc ip4StB(s: string, vb: var VBuffer): bool = ## IPv4 stringToBuffer() implementation. diff --git a/libp2p/multibase.nim b/libp2p/multibase.nim index 954228e..5e0b9e9 100644 --- a/libp2p/multibase.nim +++ b/libp2p/multibase.nim @@ -38,7 +38,7 @@ type encl: MBCodeSize decl: MBCodeSize - MultiBaseError* = object of Exception + MultiBaseError* = object of CatchableError proc idd(inbytes: openarray[char], outbytes: var openarray[byte], outlen: var int): MultibaseStatus = diff --git a/libp2p/multicodec.nim b/libp2p/multicodec.nim index b32422a..bace648 100644 --- a/libp2p/multicodec.nim +++ b/libp2p/multicodec.nim @@ -230,7 +230,7 @@ const MultiCodecList = [ type MultiCodec* = distinct int - MultiCodecError* = object of Exception + MultiCodecError* = object of CatchableError const InvalidMultiCodec* = MultiCodec(-1) diff --git a/libp2p/multihash.nim b/libp2p/multihash.nim index 6b4311e..c21b9ca 100644 --- a/libp2p/multihash.nim +++ b/libp2p/multihash.nim @@ -44,7 +44,7 @@ type size*: int dpos*: int - MultiHashError* = object of Exception + MultiHashError* = object of CatchableError proc identhash(data: openarray[byte], output: var openarray[byte]) = if len(output) > 0: diff --git a/libp2p/peer.nim b/libp2p/peer.nim index dc9d1be..a9b144d 100644 --- a/libp2p/peer.nim +++ b/libp2p/peer.nim @@ -20,7 +20,7 @@ type PeerID* = object data*: seq[byte] - PeerIDError* = object of Exception + PeerIDError* = object of CatchableError proc pretty*(pid: PeerID): string {.inline.} = ## Return base58 encoded ``pid`` representation. diff --git a/libp2p/varint.nim b/libp2p/varint.nim index 68e4e83..69fd910 100644 --- a/libp2p/varint.nim +++ b/libp2p/varint.nim @@ -35,7 +35,7 @@ type LPSomeVarint* = LPSomeUVarint SomeVarint* = PBSomeVarint | LPSomeVarint SomeUVarint* = PBSomeUVarint | LPSomeUVarint - VarintError* = object of Exception + VarintError* = object of CatchableError proc vsizeof*(x: SomeVarint): int {.inline.} = ## Returns number of bytes required to encode integer ``x`` as varint.