Skip to content

Commit

Permalink
Clarify exception message
Browse files Browse the repository at this point in the history
Clarify exception message by introducing the other token's name

#2021
  • Loading branch information
smcvb committed Dec 7, 2021
1 parent 8c6609c commit 04b4dfd
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* Copyright (c) 2010-2019. Axon Framework
* Copyright (c) 2010-2021. Axon Framework
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -18,13 +18,14 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.axonframework.common.Assert;

import java.beans.ConstructorProperties;
import java.io.Serializable;
import java.util.Objects;
import java.util.OptionalLong;

import static org.axonframework.common.Assert.isTrue;

/**
* Tracking token based on the global sequence number of an event.
*
Expand Down Expand Up @@ -80,9 +81,10 @@ public GlobalSequenceTrackingToken next() {

@Override
public TrackingToken lowerBound(TrackingToken other) {
Assert.isTrue(other instanceof GlobalSequenceTrackingToken, () -> "Incompatible token type provided.");
GlobalSequenceTrackingToken otherToken = (GlobalSequenceTrackingToken) other;
isTrue(other instanceof GlobalSequenceTrackingToken,
() -> "Incompatible token type provided:" + other.getClass().getSimpleName());

GlobalSequenceTrackingToken otherToken = (GlobalSequenceTrackingToken) other;
if (otherToken.globalIndex < this.globalIndex) {
return otherToken;
} else {
Expand All @@ -92,7 +94,9 @@ public TrackingToken lowerBound(TrackingToken other) {

@Override
public TrackingToken upperBound(TrackingToken other) {
Assert.isTrue(other instanceof GlobalSequenceTrackingToken, () -> "Incompatible token type provided.");
isTrue(other instanceof GlobalSequenceTrackingToken,
() -> "Incompatible token type provided:" + other.getClass().getSimpleName());

if (((GlobalSequenceTrackingToken) other).globalIndex > this.globalIndex) {
return other;
}
Expand All @@ -101,8 +105,8 @@ public TrackingToken upperBound(TrackingToken other) {

@Override
public boolean covers(TrackingToken other) {
Assert.isTrue(other == null || other instanceof GlobalSequenceTrackingToken,
() -> "Incompatible token type provided:" + other.getClass().getSimpleName());
isTrue(other == null || other instanceof GlobalSequenceTrackingToken,
() -> "Incompatible token type provided:" + (other != null ? other.getClass().getSimpleName() : "null"));
GlobalSequenceTrackingToken otherToken = (GlobalSequenceTrackingToken) other;

return otherToken == null || otherToken.globalIndex <= this.globalIndex;
Expand Down

0 comments on commit 04b4dfd

Please sign in to comment.