diff options
author | soshial <soshial@users.noreply.github.com> | 2021-09-30 16:43:58 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 16:43:58 +0400 |
commit | c7a7f1e016f952cfaf9fe2e54d300a5259fa3676 (patch) | |
tree | 966821e8cc44ccbf9da4408e82251185efdd1497 /src/main/java/org | |
parent | c1b406b6fcc442f96f9698774f5544ec9a0588e9 (diff) | |
download | traccar-server-c7a7f1e016f952cfaf9fe2e54d300a5259fa3676.tar.gz traccar-server-c7a7f1e016f952cfaf9fe2e54d300a5259fa3676.tar.bz2 traccar-server-c7a7f1e016f952cfaf9fe2e54d300a5259fa3676.zip |
Improve OpenCellId logging
Add error message received from OpenCellId geolocation provider
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java b/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java index cb3094e16..5e9779f2d 100644 --- a/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java +++ b/src/main/java/org/traccar/geolocation/OpenCellIdGeolocationProvider.java @@ -48,8 +48,14 @@ 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")); + callback.onFailure(new GeolocationException("Coordinates are missing.")); } } |