airbrake-ruby 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaad02409926687bb224ce9b635ba755d70ae2ca
4
- data.tar.gz: 4cf429a9c5cfc4f440ee674ab8c06105447e08a2
3
+ metadata.gz: cf59f6fb5b27ba10198dbb6c0dd4581239535ac3
4
+ data.tar.gz: 3d046a2369cfb7eabf7765e1728f81482ae0f039
5
5
  SHA512:
6
- metadata.gz: 4ad0da44bc123bb6c14387d14772796bfefdbbdf8f143285ba839867051771939faf3a2d9ff328f5f3f89231b4a0c7560038eec45601731ec8e6d32d9bd05530
7
- data.tar.gz: 26199fd126b11a6ea0a7449ff41591760ffd9642b8eef9c20f7f0e3cb041acb13ba0d1be70d40526a470458374896f086dd3b0c4a7cff657204eb189a02cb165
6
+ metadata.gz: 981beea055633c18d1ccfe83f1e1651abb308536c155f18960103f00447d6572351281cd8992db7d1ea2ca8dce935480805916f86af5f964ef1a915fdc96f2aa
7
+ data.tar.gz: db5f9c67510d7a09d985ab4411edd8b148cf03e96c171e22dd2528a6189c5809722c4c555e1c3aeb76101a7ecdf91bf2dafe951d22a7a901cc02a6ce87bb7661
@@ -64,6 +64,22 @@ module Airbrake
64
64
  )
65
65
  \z/x
66
66
 
67
+ ##
68
+ # @return [Regexp] the template that matches CoffeeScript backtraces
69
+ # usually coming from Rails & ExecJS
70
+ EXECJS_STACKFRAME_REGEXP = /\A
71
+ (?:
72
+ # Matches 'compile ((execjs):6692:19)'
73
+ (?<function>.+)\s\((?<file>.+):(?<line>\d+):\d+\)
74
+ |
75
+ # Matches 'bootstrap_node.js:467:3'
76
+ (?<file>.+):(?<line>\d+):\d+(?<function>)
77
+ |
78
+ # Matches the Ruby part of the backtrace
79
+ #{RUBY_STACKFRAME_REGEXP}
80
+ )
81
+ \z/x
82
+
67
83
  ##
68
84
  # Parses an exception's backtrace.
69
85
  #
@@ -73,13 +89,7 @@ module Airbrake
73
89
  def self.parse(exception, logger)
74
90
  return [] if exception.backtrace.nil? || exception.backtrace.none?
75
91
 
76
- regexp = if java_exception?(exception)
77
- JAVA_STACKFRAME_REGEXP
78
- elsif oci_exception?(exception)
79
- OCI_STACKFRAME_REGEXP
80
- else
81
- RUBY_STACKFRAME_REGEXP
82
- end
92
+ regexp = best_regexp_for(exception)
83
93
 
84
94
  exception.backtrace.map do |stackframe|
85
95
  frame = match_frame(regexp, stackframe)
@@ -109,10 +119,30 @@ module Airbrake
109
119
  class << self
110
120
  private
111
121
 
122
+ def best_regexp_for(exception)
123
+ if java_exception?(exception)
124
+ JAVA_STACKFRAME_REGEXP
125
+ elsif oci_exception?(exception)
126
+ OCI_STACKFRAME_REGEXP
127
+ elsif execjs_exception?(exception)
128
+ EXECJS_STACKFRAME_REGEXP
129
+ else
130
+ RUBY_STACKFRAME_REGEXP
131
+ end
132
+ end
133
+
112
134
  def oci_exception?(exception)
113
135
  defined?(OCIError) && exception.is_a?(OCIError)
114
136
  end
115
137
 
138
+ def execjs_exception?(exception)
139
+ return false unless defined?(ExecJS::RuntimeError)
140
+ return true if exception.is_a?(ExecJS::RuntimeError)
141
+ return true if exception.cause && exception.cause.is_a?(ExecJS::RuntimeError)
142
+
143
+ false
144
+ end
145
+
116
146
  def stack_frame(match)
117
147
  { file: match[:file],
118
148
  line: (Integer(match[:line]) if match[:line]),
@@ -1,7 +1,8 @@
1
1
  ##
2
- # Defines version.
2
+ # We use Semantic Versioning v2.0.0
3
+ # More information: http://semver.org/
3
4
  module Airbrake
4
5
  ##
5
6
  # @return [String] the library version
6
- AIRBRAKE_RUBY_VERSION = '1.4.4'.freeze
7
+ AIRBRAKE_RUBY_VERSION = '1.4.5'.freeze
7
8
  end
@@ -190,5 +190,40 @@ RSpec.describe Airbrake::Backtrace do
190
190
  ).to eq(parsed_backtrace)
191
191
  end
192
192
  end
193
+
194
+ context "given an ExecJS backtrace" do
195
+ let(:bt) do
196
+ ['compile ((execjs):6692:19)',
197
+ 'eval (<anonymous>:1:10)',
198
+ '(execjs):6703:8',
199
+ 'require../helpers.exports ((execjs):1:102)',
200
+ 'Object.<anonymous> ((execjs):1:120)',
201
+ 'Object.Module._extensions..js (module.js:550:10)',
202
+ 'bootstrap_node.js:467:3',
203
+ "/opt/rubies/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'"]
204
+ end
205
+
206
+ let(:ex) { ExecJS::RuntimeError.new.tap { |e| e.set_backtrace(bt) } }
207
+
208
+ let(:parsed_backtrace) do
209
+ [{ file: '(execjs)', line: 6692, function: 'compile' },
210
+ { file: '<anonymous>', line: 1, function: 'eval' },
211
+ { file: '(execjs)', line: 6703, function: '' },
212
+ { file: '(execjs)', line: 1, function: 'require../helpers.exports' },
213
+ { file: '(execjs)', line: 1, function: 'Object.<anonymous>' },
214
+ { file: 'module.js', line: 550, function: 'Object.Module._extensions..js' },
215
+ { file: 'bootstrap_node.js', line: 467, function: '' },
216
+ { file: '/opt/rubies/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb',
217
+ line: 308,
218
+ function: 'realtime' }]
219
+ end
220
+
221
+ it "returns a properly formatted array of hashes" do
222
+ stub_const('ExecJS::RuntimeError', AirbrakeTestError)
223
+ expect(
224
+ described_class.parse(ex, Logger.new('/dev/null'))
225
+ ).to eq(parsed_backtrace)
226
+ end
227
+ end
193
228
  end
194
229
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -160,4 +160,3 @@ test_files:
160
160
  - spec/payload_truncator_spec.rb
161
161
  - spec/spec_helper.rb
162
162
  - spec/sync_sender_spec.rb
163
- has_rdoc: