aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-12-31 11:13:49 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-12-31 11:13:49 +1300
commit2c6c6eccf2c45bf87e16c45e3bac9872f53c12c3 (patch)
tree480d52fafcd7331244e69b46dbd3283f36fef4b4 /src/org/traccar
parentde60cf9d75d669a8078df32f7e11bf7af1970777 (diff)
downloadtrackermap-server-2c6c6eccf2c45bf87e16c45e3bac9872f53c12c3.tar.gz
trackermap-server-2c6c6eccf2c45bf87e16c45e3bac9872f53c12c3.tar.bz2
trackermap-server-2c6c6eccf2c45bf87e16c45e3bac9872f53c12c3.zip
Implement geolocation error handling
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/LocationProviderHandler.java16
-rw-r--r--src/org/traccar/location/LocationProvider.java2
-rw-r--r--src/org/traccar/location/OpenCellIdLocationProvider.java6
-rw-r--r--src/org/traccar/location/UniversalLocationProvider.java6
4 files changed, 15 insertions, 15 deletions
diff --git a/src/org/traccar/LocationProviderHandler.java b/src/org/traccar/LocationProviderHandler.java
index 5f07358ec..ca3094ac2 100644
--- a/src/org/traccar/LocationProviderHandler.java
+++ b/src/org/traccar/LocationProviderHandler.java
@@ -20,6 +20,7 @@ import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelUpstreamHandler;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.MessageEvent;
+import org.traccar.helper.Log;
import org.traccar.location.LocationProvider;
import org.traccar.model.Position;
@@ -40,8 +41,8 @@ public class LocationProviderHandler implements ChannelUpstreamHandler {
return;
}
- final MessageEvent e = (MessageEvent) evt;
- Object message = e.getMessage();
+ final MessageEvent event = (MessageEvent) evt;
+ Object message = event.getMessage();
if (message instanceof Position) {
final Position position = (Position) message;
if ((position.getOutdated() || processInvalidPositions && !position.getValid())
@@ -55,19 +56,20 @@ public class LocationProviderHandler implements ChannelUpstreamHandler {
position.setLatitude(latitude);
position.setLongitude(longitude);
position.setAccuracy(accuracy);
- Channels.fireMessageReceived(ctx, position, e.getRemoteAddress());
+ Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
}
@Override
- public void onFailure() {
- Channels.fireMessageReceived(ctx, position, e.getRemoteAddress());
+ public void onFailure(Throwable e) {
+ Log.warning("Geolocation failed", e);
+ Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
}
});
} else {
- Channels.fireMessageReceived(ctx, position, e.getRemoteAddress());
+ Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
}
} else {
- Channels.fireMessageReceived(ctx, message, e.getRemoteAddress());
+ Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
}
}
diff --git a/src/org/traccar/location/LocationProvider.java b/src/org/traccar/location/LocationProvider.java
index 47b9f8909..ed1494ec3 100644
--- a/src/org/traccar/location/LocationProvider.java
+++ b/src/org/traccar/location/LocationProvider.java
@@ -23,7 +23,7 @@ public interface LocationProvider {
void onSuccess(double latitude, double longitude, double accuracy);
- void onFailure();
+ void onFailure(Throwable e);
}
diff --git a/src/org/traccar/location/OpenCellIdLocationProvider.java b/src/org/traccar/location/OpenCellIdLocationProvider.java
index b45797b80..a9f815399 100644
--- a/src/org/traccar/location/OpenCellIdLocationProvider.java
+++ b/src/org/traccar/location/OpenCellIdLocationProvider.java
@@ -55,7 +55,7 @@ public class OpenCellIdLocationProvider implements LocationProvider {
json.getJsonNumber("lat").doubleValue(),
json.getJsonNumber("lon").doubleValue(), 0);
} else {
- callback.onFailure();
+ callback.onFailure(new IllegalArgumentException("Coordinates are missing"));
}
}
return null;
@@ -63,12 +63,12 @@ public class OpenCellIdLocationProvider implements LocationProvider {
@Override
public void onThrowable(Throwable t) {
- callback.onFailure();
+ callback.onFailure(t);
}
});
} else {
- callback.onFailure();
+ callback.onFailure(new IllegalArgumentException("No network information"));
}
}
diff --git a/src/org/traccar/location/UniversalLocationProvider.java b/src/org/traccar/location/UniversalLocationProvider.java
index 7f7028545..63ab681e7 100644
--- a/src/org/traccar/location/UniversalLocationProvider.java
+++ b/src/org/traccar/location/UniversalLocationProvider.java
@@ -19,7 +19,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.Response;
import org.traccar.Context;
-import org.traccar.helper.Log;
import org.traccar.model.Network;
import javax.json.Json;
@@ -54,12 +53,11 @@ public class UniversalLocationProvider implements LocationProvider {
@Override
public void onThrowable(Throwable t) {
- callback.onFailure();
+ callback.onFailure(t);
}
});
} catch (JsonProcessingException e) {
- Log.warning(e);
- callback.onFailure();
+ callback.onFailure(e);
}
}