lunetas 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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -55,7 +55,13 @@ module Lunetas::Candy
55
55
  before
56
56
  response(handle_call)
57
57
  rescue Exception => e
58
- response(e, e.code)
58
+ code, error = 500, e
59
+ if Lunetas::Error::BaseError === e
60
+ code = e.code
61
+ elsif development?
62
+ error = "Error: #{e.message}\nBacktrace: #{e.backtrace.join('\n')}"
63
+ end
64
+ response(error, code)
59
65
  end
60
66
 
61
67
  private
@@ -98,6 +104,10 @@ module Lunetas::Candy
98
104
  @req.session
99
105
  end
100
106
 
107
+ def development?
108
+ ENV['RAILS_ENV'] == 'development' || ENV['RACK_ENV'].nil? || ENV['RACK_ENV'] == 'development'
109
+ end
110
+
101
111
  # TODO: Polish this
102
112
  # def authenticate!
103
113
  # @current_user = User.where(:single_access_token => token).first
@@ -50,6 +50,11 @@ describe Lunetas::Candy::InstanceMethods do
50
50
  @instance.bite
51
51
  end
52
52
 
53
+ it 'should answer with a 500 if raised a runtime error' do
54
+ @instance.should_receive(:before).and_raise(StandardError)
55
+ @instance.bite.first.should == 500
56
+ end
57
+
53
58
  it 'should call to the get method' do
54
59
  @instance.should_receive(:get)
55
60
  @instance.bite
@@ -26,7 +26,7 @@ class TestClass
26
26
  end
27
27
  end
28
28
 
29
- class TestException < StandardError
29
+ class TestException < Lunetas::Error::BaseError
30
30
  def code
31
31
  400
32
32
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lunetas
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Iv\xC3\xA1n Vald\xC3\xA9s (@ivanvc)"