aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsoshial <soshial@gmail.com>2021-10-04 14:52:23 +0200
committersoshial <soshial@gmail.com>2021-10-04 14:52:23 +0200
commit7bd438a9d86b64bd1339c235c58105408e702de8 (patch)
tree04f2e9501ddcf0aaa355fd76cc78e471931b01b3 /src
parentc7a7f1e016f952cfaf9fe2e54d300a5259fa3676 (diff)
downloadtrackermap-server-7bd438a9d86b64bd1339c235c58105408e702de8.tar.gz
trackermap-server-7bd438a9d86b64bd1339c235c58105408e702de8.tar.bz2
trackermap-server-7bd438a9d86b64bd1339c235c58105408e702de8.zip
reorganise IF clause (OpenCellId)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java b/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
index 5e9779f2d..3b64a9a14 100644
--- a/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
+++ b/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java
@@ -48,14 +48,16 @@ public class OpenCellIdGeolocationProvider implements GeolocationProvider {
callback.onSuccess(
json.getJsonNumber("lat").doubleValue(),
json.getJsonNumber("lon").doubleValue(), 0);
- } else if (json.containsKey("error")) {
- String errorMessage = json.getJsonString("error").getString();
- if (json.containsKey("code")) {
- errorMessage += " Error code: " + json.getInt("code");
- }
- callback.onFailure(new GeolocationException(errorMessage));
} else {
- callback.onFailure(new GeolocationException("Coordinates are missing."));
+ if (json.containsKey("error")) {
+ String errorMessage = json.getJsonString("error").getString();
+ if (json.containsKey("code")) {
+ errorMessage += " (" + json.getInt("code") + ")";
+ }
+ callback.onFailure(new GeolocationException(errorMessage));
+ } else {
+ callback.onFailure(new GeolocationException("Coordinates are missing"));
+ }
}
}