exceptionally 1.3.0 → 1.4.0
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.
- checksums.yaml +4 -4
- data/README.md +6 -7
- data/lib/exceptionally/controller.rb +0 -8
- data/lib/exceptionally/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fdf16af0a2ab6008bdf4eecf66a1c80c62bc615
|
4
|
+
data.tar.gz: ebcf7d8e539ccd854e55574f4f1b33c6d3ffc709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aab8643a51a26b406b2f619d91daf01401a239b7cb3b299596938bda164c772e086a7a1b38002350d04b6da415514371ed020f3d9a1edd1890cad289a951011
|
7
|
+
data.tar.gz: 57bde5c707f43857bb75ee38c7622f56941e8536cf2da9e2336c8f5a08b442367715ae46eee065455ca27e4be55b2ce2233f65dfb3115dc90bed51c010bd4ce7
|
data/README.md
CHANGED
@@ -92,22 +92,21 @@ Exceptionally will handle the following errors by default:
|
|
92
92
|
* ActiveRecord::RecordInvalid
|
93
93
|
* Apipie::ParamMissing (if using [Apipie](https://github.com/Apipie/apipie-rails))
|
94
94
|
* Apipie::ParamInvalid (if using [Apipie](https://github.com/Apipie/apipie-rails))
|
95
|
-
* Pundit::NotAuthorizedError (if using [Pundit](https://github.com/elabs/pundit))
|
96
95
|
* Exceptionally errors (see below for available errors)
|
97
96
|
|
98
97
|
If there are additional errors that you want to assign status codes to and pass to Exceptionally, you can add the following to the top of your `application_controller.rb`:
|
99
98
|
|
100
99
|
```ruby
|
101
|
-
# Catch
|
102
|
-
rescue_from
|
100
|
+
# Catch SomeGem::NotAuthorizedError errors and pass them to Exceptionally
|
101
|
+
rescue_from SomeGem::NotAuthorizedError, :with => :not_authorized_error
|
103
102
|
|
104
|
-
# Tell Exceptionally you want this treated as a
|
105
|
-
def
|
106
|
-
pass_to_error_handler(error,
|
103
|
+
# Tell Exceptionally you want this treated as a 401 error
|
104
|
+
def not_authorized_error(error)
|
105
|
+
pass_to_error_handler(error, 401)
|
107
106
|
end
|
108
107
|
```
|
109
108
|
|
110
|
-
`pass_to_error_handler` takes a Ruby Exception object and
|
109
|
+
`pass_to_error_handler` takes a Ruby Exception object and a status code. If no status code is provided, it will default to 500.
|
111
110
|
|
112
111
|
## Available Errors
|
113
112
|
|
@@ -14,9 +14,6 @@ module Exceptionally
|
|
14
14
|
rescue_from Apipie::ParamMissing, :with => :missing_param
|
15
15
|
rescue_from Apipie::ParamInvalid, :with => :invalid_param
|
16
16
|
end
|
17
|
-
if defined?(Pundit)
|
18
|
-
rescue_from Pundit::NotAuthorizedError, with: :not_authorized_error
|
19
|
-
end
|
20
17
|
end
|
21
18
|
|
22
19
|
# Raise custom error
|
@@ -29,11 +26,6 @@ module Exceptionally
|
|
29
26
|
pass_to_error_handler(error, 400)
|
30
27
|
end
|
31
28
|
|
32
|
-
# Raise 401 error
|
33
|
-
def not_authorized_error(error)
|
34
|
-
pass_to_error_handler(error, 401)
|
35
|
-
end
|
36
|
-
|
37
29
|
# Raise 404 error
|
38
30
|
def missing_record_handler(error)
|
39
31
|
pass_to_error_handler(error, 404)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exceptionally
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Neil Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|