Module: RescueMe
Overview
Example: begin
method_here
rescue RescueMe.net_http_errors => error
notify_airbrake error
end
Constant Summary collapse
- VERSION =
"1.0.1"
Instance Method Summary collapse
- #active_resource_errors(opts = {}) ⇒ Object
- #net_http_errors(opts = {}) ⇒ Object
- #net_smtp_client_errors(opts = {}) ⇒ Object
- #net_smtp_errors(opts = {}) ⇒ Object
- #net_smtp_server_errors(opts = {}) ⇒ Object
Instance Method Details
#active_resource_errors(opts = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/rescue-me.rb', line 34 def active_resource_errors(opts = {}) err = net_http_errors(opts) if defined? ActiveResource::ConnectionError err.delete(Timeout::Error) err += [ActiveResource::TimeoutError, ActiveResource::SSLError, ActiveResource::ServerError] end err end |
#net_http_errors(opts = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rescue-me.rb', line 15 def net_http_errors(opts = {}) err = [Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EBADF, EOFError, SocketError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError] err << Net::HTTP::Persistent::Error if defined? Net::HTTP::Persistent::Error err << OpenSSL::SSL::SSLError if defined? OpenSSL::SSL::SSLError err end |
#net_smtp_client_errors(opts = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rescue-me.rb', line 58 def net_smtp_client_errors(opts = {}) with_auth = opts.fetch(:with_auth, false) err = [Net::SMTPFatalError, Net::SMTPSyntaxError] err << Net::SMTPAuthenticationError if with_auth err end |
#net_smtp_errors(opts = {}) ⇒ Object
69 70 71 |
# File 'lib/rescue-me.rb', line 69 def net_smtp_errors(opts = {}) net_smtp_server_errors + net_smtp_client_errors end |
#net_smtp_server_errors(opts = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rescue-me.rb', line 45 def net_smtp_server_errors(opts = {}) with_auth = opts.fetch(:with_auth, true) err = [Timeout::Error, IOError, Net::SMTPUnknownError, Net::SMTPServerBusy] err << Net::SMTPAuthenticationError if with_auth err end |