# HG changeset patch # User GP Orcullo # Date 1675685271 -28800 # Node ID 29bc2bebf1d47ba9bf582d5c4b0dfd864dbe13fd # Parent a5f58ca4629bb1d12f7c26c7ea71d754605e93f0 Generate warning instead of Exception if CTNMaxCount is exceeded for a confnode diff -r a5f58ca4629b -r 29bc2bebf1d4 ConfigTreeNode.py --- a/ConfigTreeNode.py Sat Feb 04 07:19:52 2023 +0800 +++ b/ConfigTreeNode.py Mon Feb 06 20:07:51 2023 +0800 @@ -558,9 +558,12 @@ ChildrenWithSameClass = self.Children.setdefault(CTNType, list()) # Check count if getattr(CTNClass, "CTNMaxCount", None) and len(ChildrenWithSameClass) >= CTNClass.CTNMaxCount: - raise Exception( - _("Max count ({a1}) reached for this confnode of type {a2} "). - format(a1=CTNClass.CTNMaxCount, a2=CTNType)) + + msg = _("Max count ({a1}) reached for this confnode of type {a2} ").format( + a1=CTNClass.CTNMaxCount, a2=CTNType) + self.GetCTRoot().logger.write_warning(msg) + + return None # create the final class, derived of provided confnode and template class FinalCTNClass(CTNClass, ConfigTreeNode):