Class: Glia::Errors::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/glia/errors/error.rb

Overview

Base error

Constant Summary collapse

SNAKE_CASE_REGEX =
/^[a-z0-9]+(_[a-z0-9]+)*$/.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, ref:, message: nil, error_details: nil) ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
15
# File 'lib/glia/errors/error.rb', line 10

def initialize(type:, ref:, message: nil, error_details: nil)
  @type = type
  @ref = ref
  @message = message
  @error_details = error_details
end

Instance Attribute Details

#error_detailsObject (readonly)

Returns the value of attribute error_details.



8
9
10
# File 'lib/glia/errors/error.rb', line 8

def error_details
  @error_details
end

#messageObject (readonly)

Returns the value of attribute message.



8
9
10
# File 'lib/glia/errors/error.rb', line 8

def message
  @message
end

#refObject (readonly)

Returns the value of attribute ref.



8
9
10
# File 'lib/glia/errors/error.rb', line 8

def ref
  @ref
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/glia/errors/error.rb', line 8

def type
  @type
end

Instance Method Details

#to_hObject



17
18
19
20
21
# File 'lib/glia/errors/error.rb', line 17

def to_h
  {
    type: type, ref: ref, message: message, error_details: error_details_to_h(@error_details)
  }.compact
end