lib/errors.rb in datasift-3.1.5 vs lib/errors.rb in datasift-3.2.0

- old
+ new

@@ -1,42 +1,55 @@ +# Custom error class for rescuing DataSift errors class DataSiftError < StandardError attr_reader :status attr_reader :body def initialize(http_status = nil, http_body = nil) @status = http_status @body = http_body end def message - @body == nil ? @status : @body + @body.nil? ? @status : @body end def to_s - #if both body and status were provided then message is the body otherwise the status contains the message - msg = !@body.nil? && !@status.nil? ? @body : @status - #if body is nil then status is the message body so no status is included + # If both body and status were provided then message is the body otherwise + # the status contains the message + msg = !@body.nil? && !@status.nil? ? @body : @status + # If body is nil then status is the message body so no status is included status_string = @body.nil? ? '' : "(Status #{@status}) " "#{status_string} : #{msg}" end end class NotSupportedError < DataSiftError end +# Standard error returned when receiving a 400 response from the API class BadRequestError < DataSiftError end +# Standard error returned when receiving a 401 response from the API class AuthError < DataSiftError end class ConnectionError < DataSiftError end +# Standard error returned when receiving a 404 response from the API class ApiResourceNotFoundError < DataSiftError end +# Standard error returned when receiving a 409 response from the API +class ConflictError < DataSiftError +end + +# Standard error returned when receiving a 410 response from the API +class GoneError < DataSiftError +end + class InvalidConfigError < DataSiftError end class InvalidParamError < DataSiftError end @@ -53,9 +66,12 @@ class InvalidTypeError < DataSiftError end class StreamingMessageError < DataSiftError end + class WebSocketOnWindowsError < DataSiftError end + +# Standard error returned when trying to use a method while missing parameters class BadParametersError < DataSiftError -end \ No newline at end of file +end