Better error handling in pseudowire implementation.
I refactored the pw handler to return meaningful very specific
errors for failures. As a result, I modified also the cli and rest
api implementations to use these fine grain errors accordingly.
Change-Id: I2429532f747c4560378c40be325b039ca0f5c925
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java
index d17ec10..f4a71ab 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java
@@ -437,7 +437,7 @@
}
- public static boolean configurationValidity(List<L2TunnelDescription> pseudowires) {
+ public static L2TunnelHandler.Result configurationValidity(List<L2TunnelDescription> pseudowires) {
// structures to keep pw information
// in order to see if instantiating them will create
@@ -462,13 +462,12 @@
log.debug("Verifying pseudowire {}", pw);
verifyPseudoWire(pw, labelsUsed, vlanIds, tunIds);
}
+
+ return L2TunnelHandler.Result.SUCCESS;
} catch (Exception e) {
log.error("Caught exception while validating pseudowire : {}", e.getMessage());
- return false;
+ return L2TunnelHandler.Result.CONFIGURATION_ERROR
+ .appendError(e.getMessage());
}
-
- // return true
- return true;
}
-
}