forked from rubocop/rubocop
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix rubocop/rubocop-ast#7] Reimport error from rubocop-ast
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module RuboCop | ||
# An Error exception is different from an Offense with severity 'error' | ||
# When this exception is raised, it means that RuboCop is unable to perform | ||
# a requested action (probably due to misconfiguration) and must stop | ||
# immediately, rather than carrying on | ||
class Error < StandardError; end | ||
|
||
class ValidationError < Error; end | ||
|
||
# A wrapper to display errored location of analyzed file. | ||
class ErrorWithAnalyzedFileLocation < Error | ||
def initialize(cause:, node:, cop:) | ||
@cause = cause | ||
@cop = cop | ||
@location = node.is_a?(RuboCop::AST::Node) ? node.loc : node | ||
end | ||
|
||
attr_reader :cause, :cop | ||
|
||
def line | ||
@location&.line | ||
end | ||
|
||
def column | ||
@location&.column | ||
end | ||
|
||
def message | ||
"cause: #{cause.inspect}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters