Exception: RocketPants::InvalidResource

Inherits:
Error
  • Object
show all
Defined in:
lib/rocket_pants/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Error

error_name, #error_name, http_status, #http_status

Constructor Details

#initialize(errors, *args) ⇒ InvalidResource

Returns a new instance of InvalidResource.



70
71
72
73
# File 'lib/rocket_pants/errors.rb', line 70

def initialize(errors, *args)
  @errors = errors
  super *args
end

Instance Attribute Details

#errorsObject (readonly)

Errors are ActiveModel Errors



68
69
70
# File 'lib/rocket_pants/errors.rb', line 68

def errors
  @errors
end

Instance Method Details

#contextObject



75
76
77
78
79
80
# File 'lib/rocket_pants/errors.rb', line 75

def context
  super.tap do |ctx|
    extras            = (ctx[:metadata] ||= {})
    extras[:messages] = errors.to_hash if errors
  end
end