Exception: Spikard::Errors::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/spikard/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, status_code: nil, problem_details_type: nil) ⇒ Error

Returns a new instance of Error.



8
9
10
11
12
# File 'lib/spikard/errors.rb', line 8

def initialize(message = nil, status_code: nil, problem_details_type: nil)
  super(message)
  @status_code = status_code
  @problem_details_type = problem_details_type
end

Instance Attribute Details

#problem_details_typeObject (readonly)

Returns the value of attribute problem_details_type.



6
7
8
# File 'lib/spikard/errors.rb', line 6

def problem_details_type
  @problem_details_type
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



6
7
8
# File 'lib/spikard/errors.rb', line 6

def status_code
  @status_code
end

Instance Method Details

#to_problem_detailsObject



14
15
16
17
18
19
20
21
# File 'lib/spikard/errors.rb', line 14

def to_problem_details
  {
    type: @problem_details_type || "about:blank",
    title: self.class.name.split("::").last,
    status: @status_code || 500,
    detail: message
  }
end