beekeeper 0.1.7 → 0.1.8
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 +42 -4
- data/lib/beekeeper/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2e59a97870e4ff992512cfd825ea70d3ee508c1b22299484d0e7bcb5650dec3
|
4
|
+
data.tar.gz: f329c4677c876ad554bf446f5b3bab061cf037ee86ab4881ad07ea5ddec34c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81110a70e01c7ab375c59621b79af6ea78dbcb15bf70770d5eb082e5f05e924f87a66b7a982aa39f595f847e0c43a9e333e9e42ec7aa133bb2d078c08a2d4463
|
7
|
+
data.tar.gz: 78316c16c36cf72850603d223a68b7fd5756e586f58d1d99d22df2c840616a02f7da5ef357113b6ecae268defeda86e7764eed11cf9f81c4d71c6bd0e76ca59c
|
data/README.md
CHANGED
@@ -30,16 +30,54 @@ $ gem install beekeeper
|
|
30
30
|
|
31
31
|
* Include `Beekeeper::Rescuer` in your application controller so that known errors are logged and response is returned in a standard JSON format.
|
32
32
|
* These are the `known errors` it rescues:
|
33
|
-
* `
|
34
|
-
* `BaseError`
|
33
|
+
* `Beekeeper::Error`
|
35
34
|
* `ActiveRecord::RecordInvalid` (Validation errors)
|
36
35
|
* `ActiveRecord::RecordNotFound`
|
37
36
|
|
37
|
+
* In order to define and raise known errors in your application, it is recommended that you subclass Beekeeper::Error
|
38
|
+
|
39
|
+
For example:
|
40
|
+
```ruby
|
41
|
+
class CustomError < Beekeeper::Error
|
42
|
+
end
|
43
|
+
|
44
|
+
class CustomErrors::BadRequest < CustomError
|
45
|
+
def initialize(message = "Request params are invalid")
|
46
|
+
super(error: :bad_request, status: 400, message: message)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
class UsersController
|
52
|
+
def edit
|
53
|
+
raise CustomErrors::BadRequest, message: "User not found" if params[:id].blank?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
```
|
59
|
+
|
38
60
|
* This library also inserts a `TrapApiExceptions` middleware in your Rails application stack which traps errors from an API route (`/api`) and returns a standard JSON error response by default. (Without this middleware, an HTML response is returned)
|
39
61
|
|
40
|
-
|
62
|
+
* This gem also provides standard logging for an exception message. For eg. sometimes, you would like to rescue the exception and just log the exception in the application code itself.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
|
66
|
+
class BackgroundTaskWorker < Worker
|
67
|
+
|
68
|
+
def perform
|
69
|
+
begin
|
70
|
+
#Code Body
|
71
|
+
rescue e => StandardError
|
72
|
+
Beekeeper::Logger.fatal(e)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
```
|
41
79
|
|
42
|
-
|
80
|
+
Above Beekeeper::Logger will print the error message, error class along with a trimmed version of the backtrace.
|
43
81
|
|
44
82
|
## Contributing
|
45
83
|
Contribution directions go here.
|
data/lib/beekeeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beekeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omkar Joshi
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
description: 'Beekeepeer: This gem is responsible for error logging, processing and
|
56
56
|
rendering of errors in a standard JSON format..'
|
57
57
|
email:
|
58
|
-
-
|
58
|
+
- onjoshi@ncsu.edu
|
59
59
|
executables: []
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- lib/beekeeper/trap_api_exceptions.rb
|
73
73
|
- lib/beekeeper/version.rb
|
74
74
|
- lib/tasks/beekeeper_tasks.rake
|
75
|
-
homepage: https://github.com/
|
75
|
+
homepage: https://github.com/josho1/beekeeper
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
78
|
metadata:
|