namespace ZB.MOM.WW.ScadaBridge.Transport.Import;
///
/// Thrown when the post-apply semantic validation pass detects that the merged
/// target configuration would not be deployable — e.g. a template script
/// references a SharedScript or ExternalSystem that exists in neither the
/// bundle nor the (post-merge) target database.
///
/// The exception is caught inside to
/// roll back the transaction, emit a BundleImportFailed audit row, and
/// re-throw to the caller so the UI can surface the specific errors. It is
/// deliberately distinct from so the
/// caller can distinguish "your bundle is bad" from "the import infra is bad".
///
///
public sealed class SemanticValidationException : Exception
{
/// Gets the list of semantic validation error messages that caused this exception.
public IReadOnlyList Errors { get; }
///
/// Initializes a new with the given error list.
///
/// The list of validation error messages to include in the exception.
public SemanticValidationException(IReadOnlyList errors)
: base(BuildMessage(errors))
{
Errors = errors ?? throw new ArgumentNullException(nameof(errors));
}
private static string BuildMessage(IReadOnlyList errors)
{
if (errors is null || errors.Count == 0)
{
return "Bundle semantic validation failed.";
}
return "Bundle semantic validation failed: " + string.Join("; ", errors);
}
}