Exception: Takagi::Errors::MountError

Inherits:
TakagiError
  • Object
show all
Defined in:
lib/takagi/errors.rb

Overview

Raised when nesting/mounting fails

Instance Attribute Summary

Attributes inherited from TakagiError

#context, #suggestions

Class Method Summary collapse

Methods inherited from TakagiError

#initialize

Constructor Details

This class inherits a constructor from Takagi::Errors::TakagiError

Class Method Details

.circular_nesting(controller_chain) ⇒ Object



491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/takagi/errors.rb', line 491

def self.circular_nesting(controller_chain)
  new(
    "Circular controller nesting detected",
    context: {
      chain: controller_chain.map(&:name).join('')
    },
    suggestions: [
      "Controllers cannot nest themselves directly or indirectly",
      "Restructure your controller hierarchy",
      "Chain: #{controller_chain.map(&:name).join('')}"
    ]
  )
end

.conflicting_mount(path, controller1, controller2) ⇒ Object



520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/takagi/errors.rb', line 520

def self.conflicting_mount(path, controller1, controller2)
  new(
    "Mount path conflict: #{path}",
    context: {
      path: path,
      controllers: [controller1.name, controller2.name]
    },
    suggestions: [
      "Two controllers cannot mount at the same path",
      "Use different paths: '#{path}/v1' and '#{path}/v2'",
      "Or nest one under the other"
    ]
  )
end

.invalid_mount_path(path, reason) ⇒ Object



505
506
507
508
509
510
511
512
513
514
515
516
517
518
# File 'lib/takagi/errors.rb', line 505

def self.invalid_mount_path(path, reason)
  new(
    "Invalid mount path: #{path.inspect}",
    context: {
      path: path,
      reason: reason
    },
    suggestions: [
      "Mount paths must start with '/'",
      "Example: mount '/api' or mount '/telemetry'",
      "Avoid trailing slashes: '/api' not '/api/'"
    ]
  )
end