Class: Svelte::Errors::CompilerError
- Inherits:
-
ActiveSupport::SyntaxErrorProxy
- Object
- ActiveSupport::SyntaxErrorProxy
- Svelte::Errors::CompilerError
- Defined in:
- lib/svelte/errors.rb
Overview
steep:ignore UnknownConstant
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#suggestion ⇒ Object
Returns the value of attribute suggestion.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
- #annotated_source_code ⇒ Object
- #backtrace ⇒ Object
- #backtrace_locations ⇒ Object
- #bindings ⇒ Object
- #cause ⇒ Object
-
#initialize(error) ⇒ CompilerError
constructor
A new instance of CompilerError.
- #message ⇒ Object
Constructor Details
#initialize(error) ⇒ CompilerError
Returns a new instance of CompilerError.
8 9 10 11 12 13 14 15 |
# File 'lib/svelte/errors.rb', line 8 def initialize(error) @file = error[:id] @line = error.dig(:start, :line) @sugggestion = error.dig(:suggestion) || "" # steep:ignore:start super(error[:pluginCode]) # : self # steep:ignore:end end |
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
6 7 8 |
# File 'lib/svelte/errors.rb', line 6 def location @location end |
#suggestion ⇒ Object
Returns the value of attribute suggestion.
6 7 8 |
# File 'lib/svelte/errors.rb', line 6 def suggestion @suggestion end |
#template ⇒ Object
Returns the value of attribute template.
6 7 8 |
# File 'lib/svelte/errors.rb', line 6 def template @template end |
Instance Method Details
#annotated_source_code ⇒ Object
46 47 48 49 50 51 |
# File 'lib/svelte/errors.rb', line 46 def annotated_source_code location[:lineText].split("\n").map.with_index(1) { |line, index| indentation = " " * 4 "#{index}:#{indentation}#{line}" } end |
#backtrace ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/svelte/errors.rb', line 21 def backtrace if suggestion ["#{Rails.root.join @file}:#{@line}:#{}, #{suggestion}"] + caller else ["#{Rails.root.join @file}:#{@line}:#{}"] + caller end end |
#backtrace_locations ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/svelte/errors.rb', line 37 def backtrace_locations traces = backtrace.map { |trace| file, line = trace.match(/^(.+?):(\d+).*$/, &:captures) || trace ActiveSupport::SyntaxErrorProxy::BacktraceLocation.new(file, line.to_i, trace) # steep:ignore UnknownConstant } traces.map { |loc| ActiveSupport::SyntaxErrorProxy::BacktraceLocationProxy.new(loc, self) } # steep:ignore UnknownConstant end |
#bindings ⇒ Object
33 34 35 |
# File 'lib/svelte/errors.rb', line 33 def bindings [template.send(:binding)] end |
#cause ⇒ Object
29 30 31 |
# File 'lib/svelte/errors.rb', line 29 def cause nil end |
#message ⇒ Object
17 18 19 |
# File 'lib/svelte/errors.rb', line 17 def to_s end |