Skip to content

Commit

Permalink
Correct error messages. Add check for sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
OptimumCode committed Oct 13, 2023
1 parent 10b5a8f commit 93c297b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ private class BuilderImpl : EventId.Builder {
if (_id == null || _book == null || _scope == null || _timestamp == null) {
val missing = StringJoiner(",", "[", "]")
if (_id == null) {
missing.add(" id")
missing.add("id")
}
if (_book == null) {
missing.add(" book")
missing.add("book")
}
if (_scope == null) {
missing.add(" scope")
missing.add("scope")
}
if (_timestamp == null) {
missing.add(" timestamp")
missing.add("timestamp")
}
error("Missing required properties:$missing")
error("Missing required properties: $missing")
}
return EventId(
_id!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private class MessageIdBuilderImpl : MessageId.Builder {
override fun isDirectionSet(): Boolean = _direction != null

override fun setSequence(sequence: Long): MessageId.Builder = apply {
require(sequence > SEQUENCE_NOT_SET) { "Property \"sequence\" should not be negative" }
this._sequence = sequence
}

Expand Down Expand Up @@ -172,18 +173,18 @@ private class MessageIdBuilderImpl : MessageId.Builder {
if (_sessionAlias == null || _direction == null || _sequence == SEQUENCE_NOT_SET || _timestamp == null) {
val missing = StringJoiner(",", "[", "]")
if (_sessionAlias == null) {
missing.add(" sessionAlias")
missing.add("sessionAlias")
}
if (_direction == null) {
missing.add(" direction")
missing.add("direction")
}
if (_sequence == SEQUENCE_NOT_SET) {
missing.add(" sequence")
missing.add("sequence")
}
if (_timestamp == null) {
missing.add(" timestamp")
missing.add("timestamp")
}
error("Missing required properties:$missing")
error("Missing required properties: $missing")
}
return MessageId(
_sessionAlias!!,
Expand Down

0 comments on commit 93c297b

Please sign in to comment.