Exception: Takagi::Errors::ValidationError

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

Overview

Raised when validation 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

.invalid_process_count(value) ⇒ Object



457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'lib/takagi/errors.rb', line 457

def self.invalid_process_count(value)
  new(
    "Invalid process count: #{value.inspect}",
    context: {
      provided: value,
      type: value.class,
      expected: "Positive integer (1..32)"
    },
    suggestions: [
      "Use a positive integer: set :processes, 4",
      "Typical values: 1 (simple), 4 (moderate), 8 (high scale)",
      "Or use a profile: profile :high_throughput"
    ]
  )
end

.invalid_thread_count(value) ⇒ Object



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/takagi/errors.rb', line 441

def self.invalid_thread_count(value)
  new(
    "Invalid thread count: #{value.inspect}",
    context: {
      provided: value,
      type: value.class,
      expected: "Positive integer (1..100)"
    },
    suggestions: [
      "Use a positive integer: threads 4",
      "Typical values: 1 (minimal), 4 (balanced), 8 (high load)",
      "Or use a profile: profile :high_throughput"
    ]
  )
end

.missing_required_param(param_name, available_params) ⇒ Object



473
474
475
476
477
478
479
480
481
482
483
484
485
486
# File 'lib/takagi/errors.rb', line 473

def self.missing_required_param(param_name, available_params)
  new(
    "Missing required parameter: #{param_name.inspect}",
    context: {
      required: param_name,
      received: available_params.empty? ? "(no params)" : available_params.keys
    },
    suggestions: [
      "Include #{param_name.inspect} in request payload",
      "Example: coap-client -m post coap://host/path -e '{\"#{param_name}\":\"value\"}'",
      "Or make it optional: params.fetch(:#{param_name}, default_value)"
    ]
  )
end