diff options
| author | Weston Ganger <[email protected]> | 2022-01-24 13:51:27 -0800 |
|---|---|---|
| committer | Weston Ganger <[email protected]> | 2022-01-24 13:51:27 -0800 |
| commit | 34a287b33364657bc340e98be846b65fa8a77922 (patch) | |
| tree | 1a96879cb2481ea3576b3d487aabe51d5a80edca /lib | |
| parent | 6bc6e6303ac27ac11571760c036c244b1448aeaa (diff) | |
| download | caxlsx-34a287b33364657bc340e98be846b65fa8a77922.tar.gz caxlsx-34a287b33364657bc340e98be846b65fa8a77922.zip | |
Refractor to use constant based error messages
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/util/constants.rb | 6 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/worksheet.rb | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/axlsx/util/constants.rb b/lib/axlsx/util/constants.rb index 25781983..3d67088c 100644 --- a/lib/axlsx/util/constants.rb +++ b/lib/axlsx/util/constants.rb @@ -307,6 +307,12 @@ module Axlsx # error message for non 'integerish' value ERR_INTEGERISH = "You value must be, or be castable via to_i, an Integer. You provided %s".freeze + # error message for invalid cell reference + ERR_CELL_REFERENCE_INVALID = "Invalid cell definition `%s`".freeze + + # error message for cell reference with last cell missing + ERR_CELL_REFERENCE_MISSING_CELL = "Missing cell `%s` for the specified range `%s`".freeze + # Regex to match forbidden control characters # The following will be automatically stripped from worksheets. # diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index f1ec815c..cc0e56ae 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -606,11 +606,11 @@ module Axlsx parts.first else if parts.size > 2 - raise ArgumentError.new("Invalid cell definition `#{cell_def}`") + raise ArgumentError, (ERR_CELL_REFERENCE_INVALID % cell_def) elsif parts.first.nil? - raise ArgumentError.new("Missing cell `#{cell_def.split(":").first}` for the specified range `#{cell_def}`") + raise ArgumentError, (ERR_CELL_REFERENCE_MISSING_CELL % [cell_def.split(":").first, cell_def]) elsif parts.last.nil? - raise ArgumentError.new("Missing cell `#{cell_def.split(":").last}` for the specified range `#{cell_def}`") + raise ArgumentError, (ERR_CELL_REFERENCE_MISSING_CELL % [cell_def.split(":").last, cell_def]) end range(*parts) |
