Skip to content

Commit 5e4e732

Browse files
authored
style: Fix 2 ErrorProneStyle findings (#591)
* Constructors and methods with the same name should appear sequentially with no other code in between. * This catch block catches an exception and re-throws another, but swallows the caught exception rather than setting it as a cause. This can make debugging harder. Courtesy of clshepherd/clrobot in the monorepo. Fixes #590.
1 parent ad467ef commit 5e4e732

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,16 @@ public static Value.Builder makeValue(Date date) {
483483
return Value.newBuilder().setTimestampValue(toTimestamp(date.getTime() * 1000L));
484484
}
485485

486+
/** Makes a GeoPoint value. */
487+
public static Value.Builder makeValue(LatLng value) {
488+
return Value.newBuilder().setGeoPointValue(value);
489+
}
490+
491+
/** Makes a GeoPoint value. */
492+
public static Value.Builder makeValue(LatLng.Builder value) {
493+
return makeValue(value.build());
494+
}
495+
486496
private static Timestamp.Builder toTimestamp(long microseconds) {
487497
long seconds = microseconds / MICROSECONDS_PER_SECOND;
488498
long microsecondsRemainder = microseconds % MICROSECONDS_PER_SECOND;
@@ -497,16 +507,6 @@ private static Timestamp.Builder toTimestamp(long microseconds) {
497507
.setNanos((int) microsecondsRemainder * NANOSECONDS_PER_MICROSECOND);
498508
}
499509

500-
/** Makes a GeoPoint value. */
501-
public static Value.Builder makeValue(LatLng value) {
502-
return Value.newBuilder().setGeoPointValue(value);
503-
}
504-
505-
/** Makes a GeoPoint value. */
506-
public static Value.Builder makeValue(LatLng.Builder value) {
507-
return makeValue(value.build());
508-
}
509-
510510
/**
511511
* Make a key from the specified path of kind/id-or-name pairs and/or Keys.
512512
*
@@ -545,7 +545,8 @@ public static Key.Builder makeKey(Object... elements) {
545545
try {
546546
kind = (String) element;
547547
} catch (ClassCastException e) {
548-
throw new IllegalArgumentException("Expected string or Key, got: " + element.getClass());
548+
throw new IllegalArgumentException(
549+
"Expected string or Key, got: " + element.getClass(), e);
549550
}
550551
pathElement.setKind(kind);
551552
if (pathIndex + 1 < elements.length) {

0 commit comments

Comments
 (0)