EPPlus
EPPlus copied to clipboard
Use custom exception in Validate ExcelRange.ValidateRowCol
Can you implements custom exception to allow us to intercept exception correctly. ArgumentException is for me too generic.
Current version
private static void ValidateRowCol(int Row, int Col)
{
if (Row < 1 || Row > ExcelPackage.MaxRows)
{
throw new ArgumentException("Row out of range");
}
if (Col < 1 || Col > ExcelPackage.MaxColumns)
{
throw new ArgumentException("Column out of range");
}
}
Desire version
private static void ValidateRowCol(int Row, int Col)
{
if (Row < 1)
{
throw new ArgumentOutOfRangeException("Row out of range. Cannot be inferior to 1");
}
if ( Row > ExcelPackage.MaxRows)
{
throw new RowMaximumReachedException("Maximum of rows reached", ExcelPackage.MaxRows);
}
if (Col < 1 )
{
throw new ArgumentOutOfRangeException("Column out of range. Cannot be inferior to 1");
}
if (Col > ExcelPackage.MaxColumns)
{
throw new ColumnMaximumReachedException("Maximum of column reached",ExcelPackage.MaxColumns);
}
}
I assume we can look into this for a future version. For now please validate the address before calling the range indexer.