ctws 0.1.6.alpha → 0.1.7.alpha

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: 58e4e4ba82f810cec1e53fec7fbee1fecc43ff19
4
- data.tar.gz: 34da4ce18c185822781b2cef8fde9aba35b5e46f
3
+ metadata.gz: 9d999a0fdeae91a6f66fff66e500e55cba37d901
4
+ data.tar.gz: 49804146ff19f72da8b3ae50ad2dfcf84fb6b0dd
5
5
  SHA512:
6
- metadata.gz: ff5db565d6bc6eae63d4c455749c9b86d1133c2e75b6feca1202154c3a8144ffde10f7862801a40e7245dc9c66028bb2515d8465ea369cda549fd62454ee9729
7
- data.tar.gz: 3ccccba0d7315d2eead3c86f912e66ffa68c3e340f90f173526a647610b9f11214ec5623f4d417b94ac9893b892ff5a911d0efbf5eb0eef6ae60c4151aa0bc8a
6
+ metadata.gz: 121277c534d49ef71da41a9a322b3e772d67c438a6286e285d2bfef34a635971832deacfd0366c667d950f9d2ca2bb2d69b0ef9d94f215f2fff89b82cf82c2a3
7
+ data.tar.gz: 2ce36318842960dcf50d49ed38a13fa4bb1f1e1c7e55f33ff8086a193153aab51d0a19a7376e303eb5a674d31094ceddde53ad30b9a2cfb6b275050d30b480f9
@@ -19,39 +19,35 @@ module Ctws
19
19
  included do
20
20
  # Define custom handlers
21
21
  rescue_from ActiveRecord::RecordInvalid, with: :four_twenty_two
22
- rescue_from ExceptionHandler::AuthenticationError, with: :unauthorized_request
23
22
  rescue_from ExceptionHandler::MissingToken, with: :four_twenty_two
24
23
  rescue_from ExceptionHandler::InvalidToken, with: :four_twenty_two
25
24
  rescue_from ExceptionHandler::UnprocessableEntity, with: :four_twenty_two
25
+ rescue_from ExceptionHandler::AuthenticationError, with: :unauthorized_request
26
26
  rescue_from ExceptionHandler::ExpiredSignature, with: :four_ninety_eight
27
27
  rescue_from ExceptionHandler::RoutingError, with: :not_found
28
28
  rescue_from ActiveRecord::RecordNotFound, with: :not_found
29
29
  rescue_from ActionController::RoutingError, with: :not_found
30
-
31
- rescue_from ActiveRecord::RecordInvalid do |e|
32
- json_response({ message: e.message }, :unprocessable_entity)
33
- end
30
+
34
31
  end
35
32
 
36
33
  # JSON response with message; Status code 401 - Unauthorized
37
34
  def unauthorized_request(e)
38
- json_response({ message: e.message }, :unauthorized)
35
+ json_response([{ message: e.message, error_code: "401"}], :unauthorized)
39
36
  end
40
37
 
41
- # JSON response with message; Status code 401 - Unauthorized
38
+ # JSON response with message; Status code 404 - Not Found
42
39
  def not_found(e)
43
- json_response({ message: e.message }, :not_found)
40
+ json_response([{ message: e.message, error_code: "404" }], :not_found)
44
41
  end
45
42
 
46
43
  # JSON response with message; Status code 422 - unprocessable entity
47
44
  def four_twenty_two(e)
48
- json_response({ message: e.message }, :unprocessable_entity)
45
+ json_response([{ message: e.message, error_code: "422" }], :unprocessable_entity)
49
46
  end
50
47
 
51
-
52
48
  # JSON response with message; Status code 498 - Invalid Token
53
49
  def four_ninety_eight(e)
54
- json_response({ message: e.message }, :invalid_token)
50
+ json_response([{ message: e.message, error_code: "498" }], :invalid_token)
55
51
  end
56
52
 
57
53
  end
data/lib/ctws/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ctws
2
- VERSION = '0.1.6.alpha'
2
+ VERSION = '0.1.7.alpha'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6.alpha
4
+ version: 0.1.7.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustí B.R.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails