Exception: Fontisan::VariationError

Inherits:
Error
  • Object
show all
Defined in:
lib/fontisan/error.rb

Overview

Base variation error with context and suggestions

Provides detailed error information including context hash and actionable suggestions for resolution.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, context: {}, suggestion: nil) ⇒ VariationError

Initialize variation error

Parameters:

  • message (String)

    Error message

  • context (Hash) (defaults to: {})

    Error context

  • suggestion (String, nil) (defaults to: nil)

    Suggested fix



34
35
36
37
38
# File 'lib/fontisan/error.rb', line 34

def initialize(message, context: {}, suggestion: nil)
  super(message)
  @context = context
  @suggestion = suggestion
end

Instance Attribute Details

#contextHash (readonly)

Returns Error context (axis, value, range, etc.).

Returns:

  • (Hash)

    Error context (axis, value, range, etc.)



24
25
26
# File 'lib/fontisan/error.rb', line 24

def context
  @context
end

#suggestionString? (readonly)

Returns Suggested fix.

Returns:

  • (String, nil)

    Suggested fix



27
28
29
# File 'lib/fontisan/error.rb', line 27

def suggestion
  @suggestion
end

Instance Method Details

#detailed_messageString

Get detailed error message with context and suggestion

Returns:

  • (String)

    Formatted error message



43
44
45
46
47
48
# File 'lib/fontisan/error.rb', line 43

def detailed_message
  msg = message
  msg += "\nContext: #{@context.inspect}" if @context.any?
  msg += "\nSuggestion: #{@suggestion}" if @suggestion
  msg
end