mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-08 00:43:06 +00:00
chore: Better feedback invalid content topic (#2254)
* typo correction appplication -> application * content_topic.nim: better feedback to user when wrong topic is passed * test_namespaced_topics.nim: updating tests accordingly
This commit is contained in:
parent
2d27c47c82
commit
7f9a0d97fd
@ -89,7 +89,7 @@ suite "Waku Message - Content topics namespacing":
|
|||||||
let err = ns.tryError()
|
let err = ns.tryError()
|
||||||
check:
|
check:
|
||||||
err.kind == ParsingErrorKind.InvalidFormat
|
err.kind == ParsingErrorKind.InvalidFormat
|
||||||
err.cause == "invalid topic structure"
|
err.cause == "Invalid content topic structure. Expected either /<application>/<version>/<topic-name>/<encoding> or /<gen>/<application>/<version>/<topic-name>/<encoding>"
|
||||||
|
|
||||||
test "Parse content topic string - Invalid string: missing encoding part":
|
test "Parse content topic string - Invalid string: missing encoding part":
|
||||||
## Given
|
## Given
|
||||||
@ -104,7 +104,7 @@ suite "Waku Message - Content topics namespacing":
|
|||||||
let err = ns.tryError()
|
let err = ns.tryError()
|
||||||
check:
|
check:
|
||||||
err.kind == ParsingErrorKind.InvalidFormat
|
err.kind == ParsingErrorKind.InvalidFormat
|
||||||
err.cause == "invalid topic structure"
|
err.cause == "Invalid content topic structure. Expected either /<application>/<version>/<topic-name>/<encoding> or /<gen>/<application>/<version>/<topic-name>/<encoding>"
|
||||||
|
|
||||||
test "Parse content topic string - Invalid string: wrong extra parts":
|
test "Parse content topic string - Invalid string: wrong extra parts":
|
||||||
## Given
|
## Given
|
||||||
|
|||||||
@ -74,7 +74,7 @@ proc parse*(T: type NsContentTopic, topic: ContentTopic|string): ParsingResult[N
|
|||||||
of 4:
|
of 4:
|
||||||
let app = parts[0]
|
let app = parts[0]
|
||||||
if app.len == 0:
|
if app.len == 0:
|
||||||
return err(ParsingError.missingPart("appplication"))
|
return err(ParsingError.missingPart("application"))
|
||||||
|
|
||||||
let ver = parts[1]
|
let ver = parts[1]
|
||||||
if ver.len == 0:
|
if ver.len == 0:
|
||||||
@ -100,7 +100,7 @@ proc parse*(T: type NsContentTopic, topic: ContentTopic|string): ParsingResult[N
|
|||||||
|
|
||||||
let app = parts[1]
|
let app = parts[1]
|
||||||
if app.len == 0:
|
if app.len == 0:
|
||||||
return err(ParsingError.missingPart("appplication"))
|
return err(ParsingError.missingPart("application"))
|
||||||
|
|
||||||
let ver = parts[2]
|
let ver = parts[2]
|
||||||
if ver.len == 0:
|
if ver.len == 0:
|
||||||
@ -116,7 +116,9 @@ proc parse*(T: type NsContentTopic, topic: ContentTopic|string): ParsingResult[N
|
|||||||
|
|
||||||
return ok(NsContentTopic.init(some(gen), app, ver, name, enc))
|
return ok(NsContentTopic.init(some(gen), app, ver, name, enc))
|
||||||
else:
|
else:
|
||||||
return err(ParsingError.invalidFormat("invalid topic structure"))
|
|
||||||
|
let errMsg = "Invalid content topic structure. Expected either /<application>/<version>/<topic-name>/<encoding> or /<gen>/<application>/<version>/<topic-name>/<encoding>"
|
||||||
|
return err(ParsingError.invalidFormat(errMsg))
|
||||||
|
|
||||||
# Content topic compatibility
|
# Content topic compatibility
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user