public ConstructDomainObjectRuleValidationException(Type type, IConstructDomainObjectRule invalidRule) : base($"Construct {type.Name} failed. {invalidRule.Reason}") { DomainType = type.Name; InvalidRule = invalidRule; Reason = invalidRule.Reason; }
public static void CheckRule(IConstructDomainObjectRule rule) { if (rule.IsInvalid()) { var stackTrace = new StackTrace(); throw new ConstructDomainObjectRuleValidationException(stackTrace.GetFrame(1).GetMethod().DeclaringType, rule); } }