Exception: MailSmtp::Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- MailSmtp::Error
show all
- Defined in:
- lib/mailsmtp/error.rb
Direct Known Subclasses
AuthenticationFailed, AuthenticationRequired, AuthenticationTypeNotSupported, BadSequence, BareNewline, CommandNotImplemented, CommandNotRecognized, EncryptionRequired, InvalidParameters, LineTooLong, LocalError, MessageTooLarge, ParametersNotRecognized, PipeliningNotSupported, ServiceUnavailable, TooManyRecipients
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.assert_status! ⇒ Object
31
32
33
34
35
|
# File 'lib/mailsmtp/error.rb', line 31
def assert_status!
if code.nil? || text.nil? || enhanced.nil?
raise "MailSmtp::Error subclass #{self} must declare status"
end
end
|
.code ⇒ Object
37
38
39
40
|
# File 'lib/mailsmtp/error.rb', line 37
def code
return @code if instance_variable_defined?(:@code)
superclass.code if superclass < Error
end
|
.enhanced ⇒ Object
47
48
49
50
|
# File 'lib/mailsmtp/error.rb', line 47
def enhanced
return @enhanced if instance_variable_defined?(:@enhanced)
superclass.enhanced if superclass < Error
end
|
.inherited(subclass) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/mailsmtp/error.rb', line 11
def inherited(subclass)
if caller_locations(1, 1).first&.label == "Class#initialize"
TracePoint.trace(:c_return) do |tp|
next unless tp.method_id == :initialize &&
tp.defined_class == Class &&
tp.return_value.equal?(subclass)
tp.disable
subclass.assert_status!
end
else
TracePoint.trace(:end) do |tp|
next unless tp.self.equal?(subclass)
tp.disable
subclass.assert_status!
end
end
end
|
.status(code, text, enhanced:) ⇒ Object
enhanced is an RFC 2034 / 3463 status like "5.3.4".
5
6
7
8
9
|
# File 'lib/mailsmtp/error.rb', line 5
def status(code, text, enhanced:)
@code = code
@text = text
@enhanced = enhanced
end
|
.text ⇒ Object
42
43
44
45
|
# File 'lib/mailsmtp/error.rb', line 42
def text
return @text if instance_variable_defined?(:@text)
superclass.text if superclass < Error
end
|
Instance Method Details
#response ⇒ Object
53
54
55
56
|
# File 'lib/mailsmtp/error.rb', line 53
def response
self.class.assert_status!
"#{self.class.code} #{self.class.enhanced} #{self.class.text}"
end
|