Add enum hooks to log parseHook jsony errors
This commit is contained in:
parent
6a7e56b613
commit
da4d6eabdd
|
@ -82,6 +82,8 @@ proc parseUnifiedCard*(json: string): Card =
|
||||||
component.parseMedia(card, result)
|
component.parseMedia(card, result)
|
||||||
of buttonGroup:
|
of buttonGroup:
|
||||||
discard
|
discard
|
||||||
|
of unknown:
|
||||||
|
echo "ERROR: Unknown component type: ", json
|
||||||
|
|
||||||
case component.kind
|
case component.kind
|
||||||
of twitterListDetails:
|
of twitterListDetails:
|
||||||
|
|
|
@ -17,6 +17,7 @@ type
|
||||||
twitterListDetails
|
twitterListDetails
|
||||||
communityDetails
|
communityDetails
|
||||||
mediaWithDetailsHorizontal
|
mediaWithDetailsHorizontal
|
||||||
|
unknown
|
||||||
|
|
||||||
Component* = object
|
Component* = object
|
||||||
kind*: ComponentType
|
kind*: ComponentType
|
||||||
|
@ -77,3 +78,28 @@ converter fromText*(text: Text): string = text.content
|
||||||
proc renameHook*(v: var HasTypeField; fieldName: var string) =
|
proc renameHook*(v: var HasTypeField; fieldName: var string) =
|
||||||
if fieldName == "type":
|
if fieldName == "type":
|
||||||
fieldName = "kind"
|
fieldName = "kind"
|
||||||
|
|
||||||
|
proc enumHook*(s: string; v: var ComponentType) =
|
||||||
|
v = case s
|
||||||
|
of "details": details
|
||||||
|
of "media": media
|
||||||
|
of "swipeable_media": swipeableMedia
|
||||||
|
of "button_group": buttonGroup
|
||||||
|
of "app_store_details": appStoreDetails
|
||||||
|
of "twitter_list_details": twitterListDetails
|
||||||
|
of "community_details": communityDetails
|
||||||
|
of "media_with_details_horizontal": mediaWithDetailsHorizontal
|
||||||
|
else: echo "ERROR: Unknown enum value (ComponentType): ", s; unknown
|
||||||
|
|
||||||
|
proc enumHook*(s: string; v: var AppType) =
|
||||||
|
v = case s
|
||||||
|
of "android_app": androidApp
|
||||||
|
of "iphone_app": iPhoneApp
|
||||||
|
of "ipad_app": iPadApp
|
||||||
|
else: echo "ERROR: Unknown enum value (AppType): ", s; androidApp
|
||||||
|
|
||||||
|
proc enumHook*(s: string; v: var MediaType) =
|
||||||
|
v = case s
|
||||||
|
of "video": video
|
||||||
|
of "photo": photo
|
||||||
|
else: echo "ERROR: Unknown enum value (MediaType): ", s; photo
|
||||||
|
|
Loading…
Reference in New Issue