From d15841424793c84cd94311da7bfb59afe65c9b82 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Thu, 11 May 2023 14:04:04 +0200 Subject: [PATCH] remove argument exception mapping --- src/FsSpreadsheet/Cells/FsCellsCollection.fs | 14 ++++++-------- src/FsSpreadsheet/FsWorksheet.fs | 7 +++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/FsSpreadsheet/Cells/FsCellsCollection.fs b/src/FsSpreadsheet/Cells/FsCellsCollection.fs index 462016b7..fee602dc 100644 --- a/src/FsSpreadsheet/Cells/FsCellsCollection.fs +++ b/src/FsSpreadsheet/Cells/FsCellsCollection.fs @@ -694,14 +694,12 @@ type FsCellsCollection() = /// Returns the upper left corner of the FsCellsCollection. /// member this.GetFirstAddress() = - try - let minRow = _rowsCollection.Keys |> Seq.min - let minCol = - _rowsCollection.Values - |> Seq.minBy (fun d -> Seq.min d.Keys) - |> fun d -> Seq.min d.Keys - FsAddress(minRow, minCol) - with :? System.ArgumentException -> FsAddress(0, 0) + let minRow = _rowsCollection.Keys |> Seq.min + let minCol = + _rowsCollection.Values + |> Seq.minBy (fun d -> Seq.min d.Keys) + |> fun d -> Seq.min d.Keys + FsAddress(minRow, minCol) /// /// Returns the upper left corner of a given FsCellsCollection. diff --git a/src/FsSpreadsheet/FsWorksheet.fs b/src/FsSpreadsheet/FsWorksheet.fs index dbd83887..1665c6d8 100644 --- a/src/FsSpreadsheet/FsWorksheet.fs +++ b/src/FsSpreadsheet/FsWorksheet.fs @@ -286,10 +286,9 @@ type FsWorksheet (name, fsRows, fsTables, fsCellsCollection) = /// Returns the highest index of any FsRow. /// member self.GetMaxRowIndex() = - try - self.Rows - |> List.maxBy (fun r -> r.Index) - with :? System.ArgumentException -> failwith "The FsWorksheet has no FsRows." + if self.Rows.IsEmpty then failwith "The FsWorksheet has no FsRows." + self.Rows + |> List.maxBy (fun r -> r.Index) /// /// Returns the highest index of any FsRow in a given FsWorksheet.