From dea97bddca0eaa59757232e36ff60f3636481a46 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Fri, 16 Feb 2024 09:33:57 -0500 Subject: [PATCH] handle NoSuchElementException as 404 --- src/main/java/io/cryostat/ExceptionMappers.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/io/cryostat/ExceptionMappers.java b/src/main/java/io/cryostat/ExceptionMappers.java index 3c166ef92..cb3bb2cae 100644 --- a/src/main/java/io/cryostat/ExceptionMappers.java +++ b/src/main/java/io/cryostat/ExceptionMappers.java @@ -15,6 +15,7 @@ */ package io.cryostat; +import java.util.NoSuchElementException; import java.util.concurrent.CompletionException; import java.util.concurrent.ExecutionException; @@ -45,6 +46,11 @@ public RestResponse mapNoResultException(NoResultException ex) { return RestResponse.notFound(); } + @ServerExceptionMapper + public RestResponse mapNoSuchElementException(NoSuchElementException ex) { + return RestResponse.notFound(); + } + @ServerExceptionMapper public RestResponse mapConstraintViolationException(ConstraintViolationException ex) { logger.warn(ex);