// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../../application_layer.dart';

/// Typed failure returned by application commands and queries.
class ApplicationFailure {
  /// Creates a `ApplicationFailure` instance with the values required by its invariants.
  /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code.
  const ApplicationFailure({
    required this.code,
    this.entityId,
    this.detailCode,
  });

  /// Stable machine-readable category.
  final ApplicationFailureCode code;

  /// Optional stable entity id related to the failure.
  final String? entityId;

  /// Optional narrower stable reason, such as a domain validation code name.
  final String? detailCode;
}
