errplane 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/errplane/black_box.rb +4 -1
- data/lib/errplane/configuration.rb +13 -8
- data/lib/errplane/rack.rb +2 -2
- data/lib/errplane/rails/middleware/hijack_render_exception.rb +4 -3
- data/lib/errplane/railtie.rb +11 -0
- data/lib/errplane/sinatra.rb +12 -0
- data/lib/errplane/transmitter.rb +6 -6
- data/lib/errplane/version.rb +1 -1
- data/lib/errplane.rb +21 -13
- metadata +3 -2
data/lib/errplane/black_box.rb
CHANGED
@@ -10,7 +10,10 @@ module Errplane
|
|
10
10
|
{
|
11
11
|
:time => Time.now.to_i,
|
12
12
|
:message => @exception.message,
|
13
|
-
:backtrace => @exception.backtrace
|
13
|
+
:backtrace => @exception.backtrace,
|
14
|
+
:message => exception.message,
|
15
|
+
:backtrace => exception.backtrace,
|
16
|
+
:exception_class => exception.class.to_s
|
14
17
|
}.to_json
|
15
18
|
end
|
16
19
|
end
|
@@ -8,22 +8,27 @@ module Errplane
|
|
8
8
|
attr_accessor :rails_environment
|
9
9
|
attr_accessor :rails_root
|
10
10
|
attr_accessor :framework
|
11
|
+
attr_accessor :framework_version
|
12
|
+
attr_accessor :language
|
13
|
+
attr_accessor :language_version
|
11
14
|
attr_accessor :ignored_exceptions
|
12
15
|
attr_accessor :ignored_environments
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
DEFAULTS = {
|
18
|
+
:api_host => "api.errplane.com",
|
19
|
+
:ignored_exceptions => %w{ActiveRecord::RecordNotFound
|
20
|
+
ActionController::RoutingError},
|
21
|
+
:ignored_environments => %w{development test cucumber selenium}
|
22
|
+
}
|
18
23
|
|
19
24
|
def initialize
|
20
|
-
@api_host =
|
21
|
-
@ignored_exceptions =
|
22
|
-
@ignored_environments =
|
25
|
+
@api_host = DEFAULTS[:api_host]
|
26
|
+
@ignored_exceptions = DEFAULTS[:ignored_exceptions].dup
|
27
|
+
@ignored_environments = DEFAULTS[:ignored_environments].dup
|
23
28
|
end
|
24
29
|
|
25
30
|
def ignore_current_environment?
|
26
|
-
|
31
|
+
self.ignored_environments.include?(self.rails_environment)
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
data/lib/errplane/rack.rb
CHANGED
@@ -6,9 +6,10 @@ module Errplane
|
|
6
6
|
base.send(:alias_method_chain,:render_exception,:errplane)
|
7
7
|
end
|
8
8
|
|
9
|
-
def render_exception_with_errplane(env,
|
10
|
-
|
11
|
-
|
9
|
+
def render_exception_with_errplane(env, e)
|
10
|
+
controller = env['action_controller.instance']
|
11
|
+
Errplane.transmit_to_api(e, env)
|
12
|
+
render_exception_without_errplane(env, e)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/errplane/railtie.rb
CHANGED
@@ -15,7 +15,18 @@ module Errplane
|
|
15
15
|
config.logger ||= ::Rails.logger
|
16
16
|
config.rails_environment ||= ::Rails.env
|
17
17
|
config.rails_root ||= ::Rails.root
|
18
|
+
<<<<<<< HEAD
|
18
19
|
config.framework = "Rails #{::Rails::VERSION::STRING}"
|
20
|
+
=======
|
21
|
+
<<<<<<< HEAD
|
22
|
+
config.framework = "Rails #{::Rails::VERSION::STRING}"
|
23
|
+
=======
|
24
|
+
config.framework = "Rails"
|
25
|
+
config.framework_version = ::Rails::VERSION::STRING
|
26
|
+
config.language = "Ruby"
|
27
|
+
config.language_version = RUBY_VERSION
|
28
|
+
>>>>>>> Add more configurability and some initial Sinatra support. Also add some Rails logging for debugging purposes.
|
29
|
+
>>>>>>> Add more configurability and some initial Sinatra support. Also add some Rails logging for debugging purposes.
|
19
30
|
end
|
20
31
|
|
21
32
|
if defined?(::ActionDispatch::DebugExceptions)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Errplane.configure(true) do |config|
|
2
|
+
# config.logger ||= ::Sinatra.logger
|
3
|
+
# config.rails_environment ||= ::Sinatra.environment
|
4
|
+
# config.rails_root ||= ::Sinatra.root
|
5
|
+
# config.framework = "Sinatra"
|
6
|
+
# config.framework_version = ::Sinatra::VERSION
|
7
|
+
# end
|
8
|
+
|
9
|
+
error do
|
10
|
+
Errplane.transmit_to_api(request.env['sinatra.error'], request.env)
|
11
|
+
raise request.env['sinatra.error']
|
12
|
+
end
|
data/lib/errplane/transmitter.rb
CHANGED
@@ -8,14 +8,14 @@ module Errplane
|
|
8
8
|
data = black_box.to_json
|
9
9
|
response = begin
|
10
10
|
url = "/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.rails_environment}?api_key=#{Errplane.configuration.api_key}"
|
11
|
-
::Rails.logger.info(url)
|
12
|
-
|
11
|
+
::Rails.logger.info("\nURL: #{url}")
|
12
|
+
::Rails.logger.info("\nData: #{data.inspect}")
|
13
|
+
response = http.post(url, data)
|
14
|
+
::Rails.logger.info("\nException Response: #{response.inspect}")
|
15
|
+
response
|
13
16
|
rescue Exception => e
|
14
|
-
e
|
17
|
+
# e
|
15
18
|
end
|
16
|
-
::Rails.logger.info("Exception Data: #{data}")
|
17
|
-
::Rails.logger.info("Exception Body: #{response.body}")
|
18
|
-
::Rails.logger.info("Exception Response: #{response.inspect}")
|
19
19
|
|
20
20
|
case response
|
21
21
|
when Net::HTTPSuccess
|
data/lib/errplane/version.rb
CHANGED
data/lib/errplane.rb
CHANGED
@@ -16,7 +16,8 @@ require "errplane/configuration"
|
|
16
16
|
require "errplane/transmitter"
|
17
17
|
require "errplane/rack"
|
18
18
|
|
19
|
-
require "errplane/railtie" #if defined?
|
19
|
+
require "errplane/railtie" #if defined? Rails::Railtie
|
20
|
+
require "errplane/sinatra" if defined? Sinatra::Request
|
20
21
|
|
21
22
|
module Errplane
|
22
23
|
class << self
|
@@ -32,27 +33,34 @@ module Errplane
|
|
32
33
|
@configuration ||= Configuration.new
|
33
34
|
end
|
34
35
|
|
35
|
-
def transmit_to_api(
|
36
|
-
|
36
|
+
def transmit_to_api(e, env)
|
37
|
+
begin
|
38
|
+
::Rails.logger.info("\nTransmitter: #{transmitter.inspect}")
|
39
|
+
::Rails.logger.info("\nBlack Box: #{assemble_black_box_for(e).inspect}")
|
40
|
+
::Rails.logger.info("\nIgnorable Exception? #{ignorable_exception?(e)}")
|
41
|
+
transmitter.relay(assemble_black_box_for(e)) unless ignorable_exception?(e)
|
42
|
+
rescue
|
43
|
+
configuration.logger.info("[Errplane] Something went terribly wrong. Exception failed to take off.")
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
|
-
def ignorable_exception?(
|
40
|
-
configuration.ignore_current_environment? || configuration.ignored_exceptions.include?(
|
47
|
+
def ignorable_exception?(e)
|
48
|
+
configuration.ignore_current_environment? || configuration.ignored_exceptions.include?(e.class.to_s)
|
41
49
|
end
|
42
50
|
|
43
51
|
private
|
44
|
-
def assemble_black_box_for(
|
45
|
-
exception = unwrap_exception(
|
52
|
+
def assemble_black_box_for(e, options = {})
|
53
|
+
exception = unwrap_exception(e)
|
46
54
|
black_box = BlackBox.new(exception: exception)
|
47
55
|
end
|
48
56
|
|
49
|
-
def unwrap_exception(
|
50
|
-
if
|
51
|
-
|
52
|
-
elsif
|
53
|
-
|
57
|
+
def unwrap_exception(e)
|
58
|
+
if e.respond_to?(:original_exception)
|
59
|
+
e.original_exception
|
60
|
+
elsif e.respond_to?(:continued_exception)
|
61
|
+
e.continued_exception
|
54
62
|
else
|
55
|
-
|
63
|
+
e
|
56
64
|
end
|
57
65
|
end
|
58
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: errplane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This gem provides exception reporting with Errplane for Rails 3.x applications.
|
15
15
|
email:
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- lib/errplane/rack.rb
|
32
32
|
- lib/errplane/rails/middleware/hijack_render_exception.rb
|
33
33
|
- lib/errplane/railtie.rb
|
34
|
+
- lib/errplane/sinatra.rb
|
34
35
|
- lib/errplane/transmitter.rb
|
35
36
|
- lib/errplane/version.rb
|
36
37
|
- lib/rails/generators/errplane/errplane_generator.rb
|