aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-10-07 09:21:33 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-10-07 09:21:33 -0700
commit1f37392e344faae3eb717ffe39f4c182b752ad2d (patch)
treea551502bea5b2a28bfd0d268b138497104cc5f68
parent90d5b6ff470aea80679b05ba690fe0630f111dc7 (diff)
downloadtraccar-server-1f37392e344faae3eb717ffe39f4c182b752ad2d.tar.gz
traccar-server-1f37392e344faae3eb717ffe39f4c182b752ad2d.tar.bz2
traccar-server-1f37392e344faae3eb717ffe39f4c182b752ad2d.zip
Better events API errors
-rw-r--r--src/main/java/org/traccar/api/resource/EventResource.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/api/resource/EventResource.java b/src/main/java/org/traccar/api/resource/EventResource.java
index e0ccf7020..f0a71d30d 100644
--- a/src/main/java/org/traccar/api/resource/EventResource.java
+++ b/src/main/java/org/traccar/api/resource/EventResource.java
@@ -7,7 +7,9 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.traccar.Context;
import org.traccar.api.BaseResource;
@@ -25,6 +27,9 @@ public class EventResource extends BaseResource {
@GET
public Event get(@PathParam("id") long id) throws SQLException {
Event event = Context.getDataManager().getObject(Event.class, id);
+ if (event == null) {
+ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
+ }
Context.getPermissionsManager().checkDevice(getUserId(), event.getDeviceId());
if (event.getGeofenceId() != 0) {
Context.getPermissionsManager().checkPermission(Geofence.class, getUserId(), event.getGeofenceId());