Exception: Eluvia::Errors::StandardError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, error = nil, status = nil, source = nil, no_sentry = false) ⇒ StandardError

Returns a new instance of StandardError.



7
8
9
10
11
12
13
14
15
# File 'lib/eluvia/errors/standard_error.rb', line 7

def initialize(message = nil, error = nil, status = nil, source = nil, no_sentry = false)
  super(message)
  @message = message || "We encountered unexpected error, but our developers had been already notified about it"
  @error = error || "Internal Server Error"
  @status = status || 500
  @source = source
  @timestamp = Time.current
  @no_sentry = no_sentry
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/eluvia/errors/standard_error.rb', line 5

def error
  @error
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/eluvia/errors/standard_error.rb', line 5

def message
  @message
end

#no_sentryObject (readonly)

Returns the value of attribute no_sentry.



5
6
7
# File 'lib/eluvia/errors/standard_error.rb', line 5

def no_sentry
  @no_sentry
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/eluvia/errors/standard_error.rb', line 5

def source
  @source
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/eluvia/errors/standard_error.rb', line 5

def status
  @status
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



5
6
7
# File 'lib/eluvia/errors/standard_error.rb', line 5

def timestamp
  @timestamp
end

Instance Method Details

#to_hObject



17
18
19
20
21
22
23
24
25
# File 'lib/eluvia/errors/standard_error.rb', line 17

def to_h
  {
    message: message,
    error: error,
    status: status,
    source: source,
    timestamp: timestamp
  }
end

#to_sObject



27
28
29
# File 'lib/eluvia/errors/standard_error.rb', line 27

def to_s
  to_h.to_s
end