From: Šimon Ukuš Date: Tue, 9 May 2023 13:14:16 +0000 (+0200) Subject: Refactor exception handling X-Git-Tag: v6.0.0~63 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=f7d9d095b0197762fdf15bb4f1e2d9e6eb394a0f;p=netconf.git Refactor exception handling 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š --- 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); } }