Exception: Tinify::Error
- Inherits:
-
StandardError
- Object
- StandardError
- Tinify::Error
- Defined in:
- lib/tinify/error.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, type = self.class.name.split("::").last, status = nil) ⇒ Error
constructor
A new instance of Error.
- #message ⇒ Object (also: #to_s)
Constructor Details
#initialize(message, type = self.class.name.split("::").last, status = nil) ⇒ Error
Returns a new instance of Error.
19 20 21 |
# File 'lib/tinify/error.rb', line 19 def initialize(, type = self.class.name.split("::").last, status = nil) , @type, @status = , type, status end |
Instance Attribute Details
#status ⇒ Object (readonly)
Returns the value of attribute status.
17 18 19 |
# File 'lib/tinify/error.rb', line 17 def status @status end |
Class Method Details
.create(message, type, status) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/tinify/error.rb', line 4 def create(, type, status) klass = case status when 401, 429 then AccountError when 400..499 then ClientError when 500..599 then ServerError else Error end = "No message was provided" if .to_s.empty? klass.new(, type, status) end |
Instance Method Details
#message ⇒ Object Also known as: to_s
23 24 25 26 27 28 29 |
# File 'lib/tinify/error.rb', line 23 def if status "#{@message} (HTTP #{@status}/#{@type})" else "#{@message}" end end |