Skip to content

Commit

Permalink
Change validation exceptions to unchecked exceptions (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Kuhn authored Nov 28, 2023
1 parent ecbccd7 commit 39f61f9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ allprojects {
targetCompatibility = JavaVersion.VERSION_1_8
}

version = '4.1.1'
version = '4.1.2'
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import software.amazon.cloudwatchlogs.emf.Constants;

public class DimensionSetExceededException extends Exception {
public class DimensionSetExceededException extends RuntimeException {

public DimensionSetExceededException() {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package software.amazon.cloudwatchlogs.emf.exception;

public class InvalidDimensionException extends Exception {
public class InvalidDimensionException extends IllegalArgumentException {
public InvalidDimensionException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package software.amazon.cloudwatchlogs.emf.exception;

public class InvalidMetricException extends Exception {
public class InvalidMetricException extends IllegalArgumentException {
public InvalidMetricException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package software.amazon.cloudwatchlogs.emf.exception;

public class InvalidNamespaceException extends Exception {
public class InvalidNamespaceException extends IllegalArgumentException {
public InvalidNamespaceException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package software.amazon.cloudwatchlogs.emf.exception;

public class InvalidTimestampException extends Exception {
public class InvalidTimestampException extends IllegalArgumentException {
public InvalidTimestampException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ public class DimensionSet {
* @param v1 Value of the single dimension
* @return a DimensionSet from the parameters
* @throws InvalidDimensionException if the dimension name or value is invalid
* @throws DimensionSetExceededException if the number of dimensions exceeds the limit
*/
public static DimensionSet of(String d1, String v1)
throws InvalidDimensionException, DimensionSetExceededException {
public static DimensionSet of(String d1, String v1) throws InvalidDimensionException {
return fromEntries(entryOf(d1, v1));
}

Expand All @@ -56,10 +54,9 @@ public static DimensionSet of(String d1, String v1)
* @param v2 Value of the second dimension
* @return a DimensionSet from the parameters
* @throws InvalidDimensionException if the dimension name or value is invalid
* @throws DimensionSetExceededException if the number of dimensions exceeds the limit
*/
public static DimensionSet of(String d1, String v1, String d2, String v2)
throws InvalidDimensionException, DimensionSetExceededException {
throws InvalidDimensionException {
return fromEntries(entryOf(d1, v1), entryOf(d2, v2));
}

Expand All @@ -74,10 +71,9 @@ public static DimensionSet of(String d1, String v1, String d2, String v2)
* @param v3 Value of the third dimension
* @return a DimensionSet from the parameters
* @throws InvalidDimensionException if the dimension name or value is invalid
* @throws DimensionSetExceededException if the number of dimensions exceeds the limit
*/
public static DimensionSet of(String d1, String v1, String d2, String v2, String d3, String v3)
throws InvalidDimensionException, DimensionSetExceededException {
throws InvalidDimensionException {
return fromEntries(entryOf(d1, v1), entryOf(d2, v2), entryOf(d3, v3));
}

Expand All @@ -94,11 +90,10 @@ public static DimensionSet of(String d1, String v1, String d2, String v2, String
* @param v4 Value of the fourth dimension
* @return a DimensionSet from the parameters
* @throws InvalidDimensionException if the dimension name or value is invalid
* @throws DimensionSetExceededException if the number of dimensions exceeds the limit
*/
public static DimensionSet of(
String d1, String v1, String d2, String v2, String d3, String v3, String d4, String v4)
throws InvalidDimensionException, DimensionSetExceededException {
throws InvalidDimensionException {

return fromEntries(entryOf(d1, v1), entryOf(d2, v2), entryOf(d3, v3), entryOf(d4, v4));
}
Expand All @@ -118,7 +113,6 @@ public static DimensionSet of(
* @param v5 Value of the fifth dimension
* @return a DimensionSet from the parameters
* @throws InvalidDimensionException if the dimension name or value is invalid
* @throws DimensionSetExceededException if the number of dimensions exceeds the limit
*/
public static DimensionSet of(
String d1,
Expand All @@ -131,7 +125,7 @@ public static DimensionSet of(
String v4,
String d5,
String v5)
throws InvalidDimensionException, DimensionSetExceededException {
throws InvalidDimensionException {

return fromEntries(
entryOf(d1, v1),
Expand Down

0 comments on commit 39f61f9

Please sign in to comment.