mirror of
https://github.com/logos-storage/nim-serde.git
synced 2026-01-04 22:53:09 +00:00
38 lines
1.2 KiB
Nim
38 lines
1.2 KiB
Nim
import ../utils/types
|
|
import ./types
|
|
import std/sets
|
|
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKinds: string, cbor: CborNode
|
|
): ref UnexpectedKindError =
|
|
newException(
|
|
UnexpectedKindError,
|
|
"deserialization to " & $expectedType & " failed: expected " &
|
|
expectedKinds &
|
|
" but got " & $cbor.kind,
|
|
)
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKinds: set[CborEventKind], cbor: CborNode
|
|
): ref UnexpectedKindError =
|
|
newUnexpectedKindError(expectedType, $expectedKinds, cbor)
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKind: CborEventKind, cbor: CborNode
|
|
): ref UnexpectedKindError =
|
|
newUnexpectedKindError(expectedType, {expectedKind}, cbor)
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKinds: set[CborNodeKind], cbor: CborNode
|
|
): ref UnexpectedKindError =
|
|
newUnexpectedKindError(expectedType, $expectedKinds, cbor)
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKind: CborNodeKind, cbor: CborNode
|
|
): ref UnexpectedKindError =
|
|
newUnexpectedKindError(expectedType, {expectedKind}, cbor)
|
|
|
|
proc newCborError*(msg: string): ref CborParseError =
|
|
newException(CborParseError, msg)
|