add base exception class and fix hierarchy

This commit is contained in:
Dmitriy Ryajov 2021-01-28 16:12:54 -06:00
parent a3c00af945
commit 8e3ef540ea
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
3 changed files with 10 additions and 9 deletions

View File

@ -13,8 +13,8 @@
import std/[os, osproc, strutils, tables, strtabs] import std/[os, osproc, strutils, tables, strtabs]
import pkg/[chronos, chronicles] import pkg/[chronos, chronicles]
import ../varint, ../multiaddress, ../multicodec, ../cid, ../peerid import ../varint, ../multiaddress, ../multicodec, ../cid, ../peerid
import ../wire, ../multihash, ../protobuf/minprotobuf import ../wire, ../multihash, ../protobuf/minprotobuf, ../errors
import ../crypto/crypto, ../errors import ../crypto/crypto
export export
peerid, multiaddress, multicodec, multihash, cid, crypto, wire, errors peerid, multiaddress, multicodec, multihash, cid, crypto, wire, errors
@ -155,11 +155,9 @@ type
ticket: PubsubTicket, ticket: PubsubTicket,
message: PubSubMessage): Future[bool] {.gcsafe.} message: PubSubMessage): Future[bool] {.gcsafe.}
# TODO: would be nice to be able to map other errors to DaemonError* = object of LPError
# this types with `Result.toException`, but it doesn't work DaemonRemoteError* = object of DaemonError
# in this module DaemonLocalError* = object of DaemonError
DaemonRemoteError* = object of CatchableError
DaemonLocalError* = object of CatchableError
var daemonsCount {.threadvar.}: int var daemonsCount {.threadvar.}: int

View File

@ -34,8 +34,9 @@ when defined(libp2p_expensive_metrics):
"mplex channels", labels = ["initiator", "peer"]) "mplex channels", labels = ["initiator", "peer"])
type type
TooManyChannels* = object of MuxerError MplexError* = object of MuxerError
InvalidChannelIdError* = object of MuxerError TooManyChannels* = object of MplexError
InvalidChannelIdError* = object of MplexError
Mplex* = ref object of Muxer Mplex* = ref object of Muxer
channels: array[bool, Table[uint64, LPChannel]] channels: array[bool, Table[uint64, LPChannel]]

View File

@ -17,6 +17,8 @@ import ../varint,
../multiaddress, ../multiaddress,
../errors ../errors
export errors
declareGauge(libp2p_open_streams, declareGauge(libp2p_open_streams,
"open stream instances", labels = ["type", "dir"]) "open stream instances", labels = ["type", "dir"])