api_versioning 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,26 +35,34 @@ module ApiVersioning
35
35
 
36
36
  begin
37
37
 
38
- presenters.each do |key, value|
38
+ presenters.each do |key, value|
39
39
  presenter = Api.const_get("#{key.to_s.camelize}Api").new(api_version)
40
40
  results << presenter.render(value)
41
- end
41
+ end
42
42
 
43
- render :json => results.join(','), :callback => params[:callback]
43
+ render :json => results.join(','), :callback => params[:callback]
44
44
 
45
- rescue NameError => e
46
- render_api_error "Unknown Presenter"
47
- rescue Exception => e
48
- render_api_error "Bad API Request"
49
- end
45
+ rescue NameError => e
46
+ render_api_error "Unknown Presenter", e
47
+ rescue Exception => e
48
+ render_api_error "Bad API Request", e
49
+ end
50
50
 
51
51
  end
52
-
53
- def render_api_error(message, status=400)
52
+
53
+ def render_api_error(message, status=400, exception=nil)
54
+ notify_api_error(exception) unless exception.nil?
54
55
  status_code = Rack::Utils.status_code(status)
55
56
  status_description = Rack::Utils::HTTP_STATUS_CODES[status_code]
56
57
  render :status => status, :json => { status_code: status_code, status_description: status_description, message: message }.to_json
57
- end
58
+ end
59
+
60
+ private
61
+ def notify_api_error(exception)
62
+ unless ExceptionNotifier::Notifier.nil?
63
+ ExceptionNotifier::Notifier.exception_notification(request.env, exception).deliver
64
+ end
65
+ end
58
66
 
59
67
  end
60
68
  end
@@ -1,3 +1,3 @@
1
1
  module ApiVersioning
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_versioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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-12-19 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -210,12 +210,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
210
210
  - - ! '>='
211
211
  - !ruby/object:Gem::Version
212
212
  version: '0'
213
+ segments:
214
+ - 0
215
+ hash: -3542417538236971569
213
216
  required_rubygems_version: !ruby/object:Gem::Requirement
214
217
  none: false
215
218
  requirements:
216
219
  - - ! '>='
217
220
  - !ruby/object:Gem::Version
218
221
  version: '0'
222
+ segments:
223
+ - 0
224
+ hash: -3542417538236971569
219
225
  requirements: []
220
226
  rubyforge_project:
221
227
  rubygems_version: 1.8.24