mirror of
https://github.com/logos-storage/nim-serde.git
synced 2026-01-02 13:43:06 +00:00
28 lines
785 B
Nim
28 lines
785 B
Nim
import ./stdjson
|
|
import ../utils/types
|
|
import std/sets
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKinds: string, json: JsonNode
|
|
): ref UnexpectedKindError =
|
|
let kind =
|
|
if json.isNil:
|
|
"nil"
|
|
else:
|
|
$json.kind
|
|
newException(
|
|
UnexpectedKindError,
|
|
"deserialization to " & $expectedType & " failed: expected " & expectedKinds &
|
|
" but got " & $kind,
|
|
)
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKinds: set[JsonNodeKind], json: JsonNode
|
|
): ref UnexpectedKindError =
|
|
newUnexpectedKindError(expectedType, $expectedKinds, json)
|
|
|
|
proc newUnexpectedKindError*(
|
|
expectedType: type, expectedKind: JsonNodeKind, json: JsonNode
|
|
): ref UnexpectedKindError =
|
|
newUnexpectedKindError(expectedType, {expectedKind}, json)
|