Exception: Takagi::Errors::ConfigurationError

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

Overview

Raised when configuration is invalid

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

.invalid_profile(profile_name, available_profiles) ⇒ Object



174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/takagi/errors.rb', line 174

def self.invalid_profile(profile_name, available_profiles)
  similar = RegistryError.find_similar(profile_name.to_s, available_profiles.map(&:to_s))

  new(
    "Unknown profile: #{profile_name.inspect}",
    context: {
      requested: profile_name,
      available: available_profiles
    },
    suggestions: similar.empty? ?
      ["Use one of: #{available_profiles.map(&:inspect).join(', ')}"] :
      ["Did you mean #{similar.first.to_sym.inspect}?"]
  )
end

.invalid_threads(value) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/takagi/errors.rb', line 204

def self.invalid_threads(value)
  new(
    "Thread count must be a positive integer, got: #{value.inspect}",
    context: {
      provided: value,
      type: value.class
    },
    suggestions: [
      "Use a positive integer: threads 4",
      "Or use a profile: profile :high_throughput"
    ]
  )
end

.missing_mount_path(controller_name) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/takagi/errors.rb', line 189

def self.missing_mount_path(controller_name)
  new(
    "#{controller_name} must specify a mount path",
    context: {
      controller: controller_name
    },
    suggestions: [
      "Add to #{controller_name}:",
      "  configure do",
      "    mount '/your-path'",
      "  end"
    ]
  )
end