From f7d9d095b0197762fdf15bb4f1e2d9e6eb394a0f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=A0imon=20Uku=C5=A1?= Date: Tue, 9 May 2023 15:14:16 +0200 Subject: [PATCH] Refactor exception handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Replace IllegalStateException with WebApplicationException when the process of retrieving yang model fails. This change has no impact on the status code being sent back to the user, but changes the status reason phrase from "Request failed" to "Internal Server Error". JIRA: NETCONF-964 Change-Id: I7934141c481ddb01dab410d4d04d4b23555212ab Signed-off-by: Šimon Ukuš --- .../java/org/opendaylight/yanglib/impl/YangLibProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java b/netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java index e1140a2153..dfd783eb04 100644 --- a/netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java +++ b/netconf/yanglib/src/main/java/org/opendaylight/yanglib/impl/YangLibProvider.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; +import javax.ws.rs.WebApplicationException; import org.opendaylight.mdsal.binding.api.DataBroker; import org.opendaylight.mdsal.binding.api.WriteTransaction; import org.opendaylight.mdsal.common.api.CommitInfo; @@ -194,9 +195,9 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener, Yan final var yangTextSchemaSource = yangTextSchemaFuture.get(); return yangTextSchemaSource.asCharSource(StandardCharsets.UTF_8).read(); } catch (InterruptedException | ExecutionException e) { - throw new IllegalStateException("Unable to get schema " + sourceId, e); + throw new WebApplicationException("Unable to get schema " + sourceId, e); } catch (IOException e) { - throw new IllegalStateException("Unable to read schema " + sourceId, e); + throw new WebApplicationException("Unable to read schema " + sourceId, e); } } -- 2.36.6