-
Notifications
You must be signed in to change notification settings - Fork 504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract ExceedsMaxError
as TooManyCellsError
#248
base: master
Are you sure you want to change the base?
Conversation
As a follow-up to df53d9a, this commit extracts `Roo::Excelx::ExceedsMaxError` into a class that inherits from `Roo::Error`. The new class is renamed as `Roo::TooManyCellsError` in order to clarify which maximum is being exceeded.
@@ -112,7 +110,10 @@ def initialize(filename_or_stream, options = {}) | |||
|
|||
if cell_max | |||
cell_count = ::Roo::Utils.num_cells_in_range(sheet_for(options.delete(:sheet)).dimensions) | |||
raise ExceedsMaxError.new("Excel file exceeds cell maximum: #{cell_count} > #{cell_max}") if cell_count > cell_max | |||
if cell_count > cell_max | |||
raise Roo::TooManyCellsError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail Roo::TooManyCellsError, ....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, interesting - I hadn't considered the semantic difference between raise
and fail
before. I'll update this.
I prefer @simonoff Do you think it would be better if this error class had a fixed message?
|
@stevendaniels Thanks for the feedback here. I renamed this exception because I find For someone who hasn't read the source, it's hard to know what "max" is referring to. Is it:
Even the documentation above the
If it were up to me, I'd consider renaming both the exception and the name of the param to be more intention-revealing. Just my opinion, though. I'm happy to adjust the PR if you'd prefer to keep the existing name. |
I also agree that it makes sense for the exception to match the name of the parameter, though. |
You make some good points. I agree with you: the names of both the class and the option are a bit ambiguous. Maybe something like |
As a follow-up to df53d9a, this commit
extracts
Roo::Excelx::ExceedsMaxError
into a class that inherits fromRoo::Error
.The new class is renamed as
Roo::TooManyCellsError
in order to clarifywhich maximum is being exceeded.