errplane 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- DEFAULT_API_HOST = "api.errplane.com"
15
- DEFAULT_IGNORED_EXCEPTIONS = %w{ActiveRecord::RecordNotFound
16
- ActionController::RoutingError}
17
- DEFAULT_IGNORED_ENVIRONMENTS = %w{development test cucumber selenium}
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 = DEFAULT_API_HOST
21
- @ignored_exceptions = DEFAULT_IGNORED_EXCEPTIONS.dup
22
- @ignored_environments = DEFAULT_IGNORED_ENVIRONMENTS.dup
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
- return self.ignored_environments.include?(self.rails_environment)
31
+ self.ignored_environments.include?(self.rails_environment)
27
32
  end
28
33
  end
29
34
  end
data/lib/errplane/rack.rb CHANGED
@@ -8,8 +8,8 @@ module Errplane
8
8
  begin
9
9
  response = @app.call(env)
10
10
  rescue => e
11
- Errplane.transmit_to_api(e)
12
- raise
11
+ Errplane.transmit_to_api(e, env)
12
+ raise(e)
13
13
  end
14
14
 
15
15
  response
@@ -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,exception)
10
- Errplane.transmit_to_api(exception)
11
- render_exception_without_errplane(env,exception)
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
@@ -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
@@ -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
- http.post("/api/v1/applications/#{Errplane.configuration.application_id}/exceptions/#{Errplane.configuration.rails_environment}?api_key=#{Errplane.configuration.api_key}", data)
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
@@ -1,3 +1,3 @@
1
1
  module Errplane
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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?(Rails)
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(exception)
36
- transmitter.relay(assemble_black_box_for(exception)) unless ignorable_exception?(exception)
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?(exception)
40
- configuration.ignore_current_environment? || configuration.ignored_exceptions.include?(exception.class.to_s)
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(exception, options = {})
45
- exception = unwrap_exception(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(exception)
50
- if exception.respond_to?(:original_exception)
51
- exception.original_exception
52
- elsif exception.respond_to?(:continued_exception)
53
- exception.continued_exception
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
- exception
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.3
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-10 00:00:00.000000000 Z
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