stark-rack 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.0.2 / 2013-08-21
2
+
3
+ * Propagate root cause exception to env['rack.exception']
4
+
1
5
  === 1.0.1 / 2013-08-20
2
6
 
3
7
  * Save any marshalled thrift exceptions in env['rack.exception']
data/lib/stark/rack.rb CHANGED
@@ -5,7 +5,7 @@ require 'stark/rack/verbose_protocol'
5
5
 
6
6
  class Stark::Rack
7
7
 
8
- VERSION = '1.0.1'
8
+ VERSION = '1.0.2'
9
9
 
10
10
  FORMAT = %{when: %0.4f, client: "%s", path: "%s%s", type: "%s", name: "%s", seqid: %d, error: %s\n}
11
11
 
@@ -84,7 +84,7 @@ class Stark::Rack
84
84
  def status_from_last_error(env)
85
85
  return 200 if @last_error.nil? || @last_error.first == :success
86
86
  x = @last_error.last[3]
87
- env['rack.exception'] = x
87
+ env['rack.exception'] = x.cause.nil? ? x : x.cause
88
88
  case x.type
89
89
  when Thrift::ApplicationException::UNKNOWN_METHOD
90
90
  404
@@ -1,3 +1,7 @@
1
+ class Thrift::ApplicationException
2
+ attr_accessor :cause
3
+ end
4
+
1
5
  class Stark::Rack
2
6
  class LoggingProcessor
3
7
  def initialize(handler, secondary=nil)
@@ -16,6 +20,7 @@ class Stark::Rack
16
20
  x = Thrift::ApplicationException.new(
17
21
  Thrift::ApplicationException::UNKNOWN,
18
22
  "#{e.message} (#{e.class})")
23
+ x.cause = e
19
24
  oprot.write_message_begin(name, Thrift::MessageTypes::EXCEPTION, seqid)
20
25
  x.write(oprot)
21
26
  oprot.write_message_end
data/stark-rack.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "stark-rack"
5
- s.version = "1.0.1"
5
+ s.version = "1.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Evan Phoenix"]
9
- s.date = "2013-08-20"
9
+ s.date = "2013-08-21"
10
10
  s.description = "Provides middleware for mounting Stark/Thrift services as Rack endpoints."
11
11
  s.email = ["evan@phx.io"]
12
12
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
data/test/test_rack.rb CHANGED
@@ -87,8 +87,8 @@ class TestRack < Test::Unit::TestCase
87
87
  @client.add 3, 4
88
88
  end
89
89
 
90
- assert Thrift::ApplicationException === env['rack.exception']
91
- assert env['rack.exception'].to_s =~ /^can't add/
90
+ assert_equal RangeError, env['rack.exception'].class
91
+ assert_equal "can't add", env['rack.exception'].to_s
92
92
  end
93
93
 
94
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stark-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
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: 2013-08-20 00:00:00.000000000 Z
12
+ date: 2013-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: stark