using System;
namespace Org.SbeTool.Sbe.Dll
{
///
/// Helper class that provides non-returning methods that throw common exception
/// from the generated C# code
///
public class ThrowHelper
{
///
/// Throws a when the "count" parameter is out of range
///
/// the parameter that triggered the exception
public static void ThrowCountOutOfRangeException(int count) =>
throw new ArgumentOutOfRangeException("count", $"Outside allowed range: count={count}");
///
/// Throws a when an invalid operation is invoked on a message (for example: enumerating a group past it's maximal count)
///
public static void ThrowInvalidOperationException() =>
throw new InvalidOperationException();
///
/// Throws a when the "index" parameter is out of range
///
/// the parameter that triggered the exception
public static void ThrowIndexOutOfRangeException(int index) =>
throw new IndexOutOfRangeException($"index out of range: index={index}");
///
/// Throws a when a too-small
/// is provided to a getter
///
/// The length of the too-small Span
public static void ThrowWhenSpanLengthTooSmall(int length) =>
throw new ArgumentOutOfRangeException("dst", $"dst.Length={length} is too small.");
///
/// Throws a when a too-large
/// is provided to a setter
///
/// The length of the too-large Span
public static void ThrowWhenSpanLengthTooLarge(int length) =>
throw new ArgumentOutOfRangeException("src", $"src.Length={length} is too large.");
}
}