Exception: Cliqr::Error::CliqrError Private

Inherits:
StandardError
  • Object
show all
Defined in:
lib/cliqr/error.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Base error class that others error types extend from

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_message, cause = nil) ⇒ CliqrError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set up the error to wrap another error’s trace

Parameters:

  • error_message (String)

    A short error description

  • cause (Error) (defaults to: nil)

    The cause of the error



22
23
24
25
26
27
28
29
30
# File 'lib/cliqr/error.rb', line 22

def initialize(error_message, cause = nil)
  super cause

  @error_message = error_message
  @cause = cause

  # Preserve the original exception's data if provided
  set_backtrace cause.backtrace if cause?
end

Class Attribute Details

.error_codeInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The error code based on the error condition

Returns:

  • (Integer)


13
14
15
# File 'lib/cliqr/error.rb', line 13

def error_code
  @error_code
end

Instance Method Details

#messageString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build a error message based on the cause of the error

Returns:

  • (String)

    Error message including the cause of the error



35
36
37
38
39
40
41
# File 'lib/cliqr/error.rb', line 35

def message
  if cause?
    "#{@error_message}\n\nCause: #{@cause.class} - #{@cause.message}\n"
  else
    @error_message
  end
end

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get string representation of the error

Returns:

  • (String)


46
47
48
# File 'lib/cliqr/error.rb', line 46

def to_s
  message
end