lib/spoom/deadcode/remover.rb in spoom-1.3.2 vs lib/spoom/deadcode/remover.rb in spoom-1.3.3

- old
+ new

@@ -143,11 +143,11 @@ # FOO, BAR = 42 # we need to remove FOO # ~~~ delete_chars(node.location.start_offset, next_node.location.start_offset) else # Should have been removed as a single MLHS node - raise "Unexpected case while removing constant assignment" + raise Error, "Unexpected case while removing constant assignment" end end sig { params(context: NodeContext).void } def delete_attr_accessor(context) @@ -200,11 +200,11 @@ # ~~~ # attr_reader :foo, :bar, :baz # we need to remove foo # ~~~ delete_chars(context.node.location.start_offset, next_node.location.start_offset) else - raise "Unexpected case while removing attr_accessor" + raise Error, "Unexpected case while removing attr_accessor" end insert_accessor(context.node, send_context, was_removed: false) if need_accessor end @@ -397,31 +397,31 @@ end sig { returns(Prism::Node) } def parent_node parent = @nesting.last - raise "No parent for node #{node}" unless parent + raise Error, "No parent for node #{node}" unless parent parent end sig { returns(NodeContext) } def parent_context nesting = @nesting.dup parent = nesting.pop - raise "No parent context for node #{@node}" unless parent + raise Error, "No parent context for node #{@node}" unless parent NodeContext.new(@source, @comments, parent, nesting) end sig { returns(T::Array[Prism::Node]) } def previous_nodes parent = parent_node child_nodes = parent.child_nodes.compact index = child_nodes.index(@node) - raise "Node #{@node} not found in parent #{parent}" unless index + raise Error, "Node #{@node} not found in parent #{parent}" unless index T.must(child_nodes[0...index]) end sig { returns(T.nilable(Prism::Node)) } @@ -433,11 +433,11 @@ def next_nodes parent = parent_node child_nodes = parent.child_nodes.compact index = child_nodes.index(node) - raise "Node #{@node} not found in nesting node #{parent}" unless index + raise Error, "Node #{@node} not found in nesting node #{parent}" unless index T.must(child_nodes.compact[(index + 1)..-1]) end sig { returns(T.nilable(Prism::Node)) } @@ -559,10 +559,10 @@ unless result.success? message = result.errors.map do |e| "#{e.message} (at #{e.location.start_line}:#{e.location.start_column})." end.join(" ") - raise ParserError, "Error while parsing #{location.file}: #{message}" + raise ParseError, "Error while parsing #{location.file}: #{message}" end visitor = new(location, kind) visitor.visit(result.value)