beekeeper 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +42 -4
  3. data/lib/beekeeper/version.rb +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec711a53303d9fb0e5f4ee680e81e058ffc46e1652a91ca4bee3dcb05f7b81cc
4
- data.tar.gz: 4efc54f12c5499769992c5d3e05f644d0b9fe8ff09369d31f2e9f82d8d1bf98b
3
+ metadata.gz: d2e59a97870e4ff992512cfd825ea70d3ee508c1b22299484d0e7bcb5650dec3
4
+ data.tar.gz: f329c4677c876ad554bf446f5b3bab061cf037ee86ab4881ad07ea5ddec34c6d
5
5
  SHA512:
6
- metadata.gz: ad035c428b70925a0d27bd6aa4ed1373133009c1f806df0a1b93021e4f541146460d2deeace4cbdde664ab904e46844352f61a5976545dc0b34a0827715f390f
7
- data.tar.gz: b62a386d0d7acb6270e247cb7c885211d00ca1fdf34c3498b8674e584b8b14097dc9a9e6d843118d62eb54adc15807b0926259ea8d702e81d28f3018d66a4725
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
- * `CustomErrors`
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
- ## Usage
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
- * Define `CustomErrors` in this gem and let other Rails apps inherit or use this in their apps.
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.
@@ -1,3 +1,3 @@
1
1
  module Beekeeper
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
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.7
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
- - omkar.joshi@anarock.com
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/saas-bn/beekeeper
75
+ homepage: https://github.com/josho1/beekeeper
76
76
  licenses:
77
77
  - MIT
78
78
  metadata: