Exception: Brut::Framework::Errors::NoClassForPath

Inherits:
Brut::Framework::Error show all
Defined in:
lib/brut/framework/errors/no_class_for_path.rb

Overview

Raised when a path has been declared, but the class to handle it cannot be found in the app.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class_name_path:, path_template:, name_error:) ⇒ NoClassForPath

Create the exception

Parameters:

  • class_name_path (Array<String>)

    array of names that, if joined with :: would name the class that could not be found

  • path_template (String)

    The path template that the class that couldn't be found was intended to handle

  • name_error (NameError)

    The NameError that was caught



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/brut/framework/errors/no_class_for_path.rb', line 14

def initialize(class_name_path:, path_template:, name_error:)
  @class_name_path = class_name_path
  @path_template = path_template
  module_message = if name_error.receiver == Module
                     "Could not find"
                   else
                     "Module '#{name_error.receiver}' did not have"
                   end
  message = "Cannot find page class for route '#{path_template}', which should be #{class_name_path.join("::")}. #{module_message} the class or module '#{name_error.name}'"
  super(message)
end

Instance Attribute Details

#class_name_pathArray<String> (readonly)

Array of names that, if joined with :: would name the class that could not be found

Returns:

  • (Array<String>)

    array of parts. For a class named Auth::LoginPage, would return ["Auth","LoginPage"]



5
6
7
# File 'lib/brut/framework/errors/no_class_for_path.rb', line 5

def class_name_path
  @class_name_path
end

#path_templateString (readonly)

The path template that the class that couldn't be found was intended to handle

Returns:

  • (String)

    a path template as given inside App.routes



8
9
10
# File 'lib/brut/framework/errors/no_class_for_path.rb', line 8

def path_template
  @path_template
end