struct Ameba::Rule::Lint::ShadowedException
- Ameba::Rule::Lint::ShadowedException
- Ameba::Rule::Base
- Struct
- Value
- Object
Overview
A rule that disallows a rescued exception that get shadowed by a less specific exception being rescued before a more specific exception is rescued.
For example, this is invalid:
begin
do_something
rescue Exception
handle_exception
rescue ArgumentError
handle_argument_error_exception
end
And it has to be written as follows:
begin
do_something
rescue ArgumentError
handle_argument_error_exception
rescue Exception
handle_exception
end
YAML configuration example:
Lint/ShadowedException:
Enabled: true
Defined in:
ameba/rule/lint/shadowed_exception.crConstant Summary
-
MSG =
"Exception handler has shadowed exceptions: %s"
Constructors
-
.new(config = nil)
A rule that disallows a rescued exception that get shadowed by a less specific exception being rescued before a more specific exception is rescued.
Instance Method Summary
Instance methods inherited from struct Ameba::Rule::Base
catch(source : Source)
catch,
excluded?(source)
excluded?,
group
group,
initialize
initialize,
name
name,
special?
special?,
test(source : Source, node : Crystal::ASTNode, *opts)test(source : Source) test
Constructor methods inherited from struct Ameba::Rule::Base
new
new
Class methods inherited from struct Ameba::Rule::Base
parsed_doc
parsed_doc
Constructor Detail
def self.new(config = nil)
#
A rule that disallows a rescued exception that get shadowed by a less specific exception being rescued before a more specific exception is rescued.
For example, this is invalid:
begin
do_something
rescue Exception
handle_exception
rescue ArgumentError
handle_argument_error_exception
end
And it has to be written as follows:
begin
do_something
rescue ArgumentError
handle_argument_error_exception
rescue Exception
handle_exception
end
YAML configuration example:
Lint/ShadowedException:
Enabled: true