class Stoplight::Failure
Constants
- TIME_FORMAT
Attributes
error_class[R]
@return [String]
error_message[R]
@return [String]
time[R]
@return [Time]
Public Class Methods
from_error(error)
click to toggle source
@param error [Exception] @return (see initialize)
# File lib/stoplight/failure.rb, line 19 def self.from_error(error) new(error.class.name, error.message, Time.now) end
from_json(json)
click to toggle source
@param json [String] @return (see initialize) @raise [JSON::ParserError] @raise [ArgumentError]
# File lib/stoplight/failure.rb, line 27 def self.from_json(json) object = JSON.parse(json) error_object = object['error'] error_class = error_object['class'] error_message = error_object['message'] time = Time.parse(object['time']) new(error_class, error_message, time) end
new(error_class, error_message, time)
click to toggle source
@param error_class
[String] @param error_message
[String] @param time [Time]
# File lib/stoplight/failure.rb, line 41 def initialize(error_class, error_message, time) @error_class = error_class @error_message = error_message @time = time end
Public Instance Methods
==(other)
click to toggle source
@param other [Failure] @return [Boolean]
# File lib/stoplight/failure.rb, line 49 def ==(other) error_class == other.error_class && error_message == other.error_message && time == other.time end
to_json(options = nil)
click to toggle source
@param options [Object, nil] @return [String]
# File lib/stoplight/failure.rb, line 57 def to_json(options = nil) JSON.generate( { error: { class: error_class, message: error_message }, time: time.strftime(TIME_FORMAT) }, options ) end