--- source_files: - Common/DTS.Common/Exceptions/OutOfDataException.cs generated_at: "2026-04-16T02:53:40.077798+00:00" model: "Qwen/Qwen3-Coder-Next-FP8" schema_version: 1 sha256: "a7ee94ab1b1410cf" --- # Exceptions ### 1. Purpose The `OutOfDataException` class provides a specialized exception type for scenarios where an operation attempting to read or consume data from a sequential or indexed data source exceeds the available data bounds. It extends `System.Exception` to include contextual information—the `Index` at which the shortage occurred—enabling callers to programmatically determine the position of failure during data processing, such as parsing, deserialization, or streaming operations. ### 2. Public Interface - **`OutOfDataException(string ex, long index)`** Constructor that initializes the exception with a message (`ex`) and the zero-based `index` (of type `long`) where the data shortage occurred. The `Index` property is set to the provided value. - **`Index` (read-only property of type `long`)** Gets the position (index) in the data stream or buffer where the exception was thrown due to insufficient data. ### 3. Invariants - `Index` is immutable after construction (`private set` on the property). - The `Index` value is non-negative in intended usage (though not enforced by the class itself); negative values would be semantically invalid for typical indexing. - The exception message (`Message` inherited from `Exception`) is provided at construction and remains unchanged. ### 4. Dependencies - **Depends on**: `System` namespace (specifically `System.Exception`). - **Used by**: Other modules in the `DTS.Common` namespace (or external consumers referencing `DTS.Common`) that require precise error reporting for data-read failures. No other internal dependencies are evident from this file. ### 5. Gotchas - The `Index` property is not validated for non-negativity or bounds; callers must ensure logical consistency (e.g., `Index` should not exceed the data source’s length). - The exception does not include the total data length or expected length, so callers must track or infer those separately if needed for diagnostics. - No custom serialization support is defined (e.g., `GetObjectData`), so cross-appdomain or remoting scenarios may rely on default `Exception` serialization behavior. - None identified from source alone.