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
A missing status is caught by #response, the only place the values are
ever needed. Validating it eagerly at definition time instead would mean
enabling a process-global TracePoint on every subclass — which traces
every thread, and is stranded permanently if the class body raises before
the matching event arrives.
16
17
18
19
20
|
# File 'lib/mailsmtp/error.rb', line 16
def assert_status!
if code.nil? || text.nil? || enhanced.nil?
raise "MailSmtp::Error subclass #{self} must declare status"
end
end
|
.code ⇒ Object
22
23
24
25
|
# File 'lib/mailsmtp/error.rb', line 22
def code
return @code if instance_variable_defined?(:@code)
superclass.code if superclass < Error
end
|
.enhanced ⇒ Object
32
33
34
35
|
# File 'lib/mailsmtp/error.rb', line 32
def enhanced
return @enhanced if instance_variable_defined?(:@enhanced)
superclass.enhanced if superclass < Error
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
27
28
29
30
|
# File 'lib/mailsmtp/error.rb', line 27
def text
return @text if instance_variable_defined?(:@text)
superclass.text if superclass < Error
end
|
Instance Method Details
#response ⇒ Object
38
39
40
41
|
# File 'lib/mailsmtp/error.rb', line 38
def response
self.class.assert_status!
"#{self.class.code} #{self.class.enhanced} #{self.class.text}"
end
|