class Temescal::Error
Constants
- NOT_FOUND_ERRORS
Public Class Methods
Public Instance Methods
Public: Formats the exception for logging.
Returns a String containing the relevant exception information to log via STDERR.
# File lib/temescal/error.rb, line 36 def formatted message = "\n#{@exception.class}: #{@exception.message}\n " message << @exception.backtrace.join("\n ") message << "\n\n" end
Public: Determines whether an exception should be silenced.
Returns true if the error type is configured as an ignored error, false otherwise.
# File lib/temescal/error.rb, line 53 def ignore? configuration.ignored_errors.each do |error| return true if @exception.is_a? error end false end
Public: Determines whether to use a default message (as specified in the configuration) or the exception's message for the API response.
Returns a String that's either the default message or the exception's message.
# File lib/temescal/error.rb, line 19 def message configuration.default_message || @exception.message end
Public: Determines the proper error code for the exception.
Returns a Fixnum based on the exception's type and http_status attribute (if applicable), will return a generic 500 for all others.
# File lib/temescal/error.rb, line 27 def status return 404 if NOT_FOUND_ERRORS.include? @exception.class.to_s @exception.respond_to?(:http_status) ? @exception.http_status : 500 end
Public: Gets the exception's type.
Returns a String representing the exception class name.
# File lib/temescal/error.rb, line 45 def type @exception.class.to_s end
Private Instance Methods
Private: Getter for Temescal
configuration.
# File lib/temescal/error.rb, line 64 def configuration $_temescal_configuration end