Exception: Lilac::CLI::BuildError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/lilac/cli/build/build_error.rb

Overview

Common base + formatter for build-time errors. Wraps a structured message into the multi-line shape:

lilac: build error in <file>:<line>
<snippet>          # optional
<message body>
<suggestion>       # optional

The bare-string form (raise BuildError, "...") is supported so callers that don't have a location on hand can still raise, but the formatted shape only kicks in when at: is provided.

Subclassed by Lilac::Directives::Lints::Error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, at: nil, snippet: nil, suggestion: nil) ⇒ BuildError

Returns a new instance of BuildError.



21
22
23
24
25
26
27
# File 'lib/lilac/cli/build/build_error.rb', line 21

def initialize(message = nil, at: nil, snippet: nil, suggestion: nil)
  @at = at
  @snippet = snippet
  @suggestion = suggestion
  @body = message
  super(format)
end

Instance Attribute Details

#atObject (readonly)

Returns the value of attribute at.



19
20
21
# File 'lib/lilac/cli/build/build_error.rb', line 19

def at
  @at
end

#snippetObject (readonly)

Returns the value of attribute snippet.



19
20
21
# File 'lib/lilac/cli/build/build_error.rb', line 19

def snippet
  @snippet
end

#suggestionObject (readonly)

Returns the value of attribute suggestion.



19
20
21
# File 'lib/lilac/cli/build/build_error.rb', line 19

def suggestion
  @suggestion
end