saoshyant 1.0.3 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/{json_exception_handeler.rb → exception_handler.rb} +3 -1
- data/lib/saoshyant.rb +8 -7
- data/saoshyant.gemspec +1 -3
- data/spec/saoshyant_test.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f799681f89ad3b560a80e46485547b9eb1e471f70d687682af05bbe6fa06f67
|
4
|
+
data.tar.gz: 9fc6cddcd7ba72e262585299dc2df801ae6de83858a41a08c67388e7788c0a15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '085dc244ff5d1f39092c1568408cc3357ea83b902385fd5ca03b320a71d68e5733c195bc9fdacba3a909aad0ef56e595ed7fecda3606bb1a3dbda7fe4c757cac'
|
7
|
+
data.tar.gz: e6bbe044e9a8b17dc046f60ffde6c0210bb639c68c2b60730fbf9ff150cc44df75f13ccd6e40f1d3407a987d16eef2cddb02b288dd8ddabe49e0ff9dceea6674
|
data/lib/saoshyant.rb
CHANGED
@@ -1,26 +1,27 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require 'exception_logger'
|
3
|
-
require '
|
3
|
+
require 'exception_handler'
|
4
4
|
|
5
5
|
module Saoshyant
|
6
6
|
extend ActiveSupport::Concern
|
7
|
+
include ActiveSupport::Rescuable
|
8
|
+
|
7
9
|
@@exception_klasses = {}
|
8
10
|
|
9
|
-
DEFAULT_ERROR_CODE = 500
|
10
11
|
included do
|
11
|
-
rescue_from Exception, with: :
|
12
|
+
rescue_from Exception, with: :execute_exception
|
12
13
|
end
|
13
14
|
|
14
15
|
def saoshyant_option(exception_klass, code, log = false)
|
15
|
-
Saoshyant::
|
16
|
+
Saoshyant::ExceptionHandler.validate_arguments(code, log)
|
16
17
|
return if @@exception_klasses.key?(exception_klass)
|
17
18
|
|
18
19
|
@@exception_klasses.merge!(exception_klass => {code: code, log: log})
|
19
20
|
end
|
20
21
|
|
21
|
-
def
|
22
|
-
code = Saoshyant::
|
23
|
-
log = Saoshyant::
|
22
|
+
def execute_exception ex
|
23
|
+
code = Saoshyant::ExceptionHandler.code_status ex, @@exception_klasses
|
24
|
+
log = Saoshyant::ExceptionHandler.log_status ex, @@exception_klasses
|
24
25
|
|
25
26
|
Saoshyant::ExceptionLogger.log(ex.message) if log == true
|
26
27
|
$saoshyant_response.call(code, ex.message, ex.class.inspect)
|
data/saoshyant.gemspec
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require 'version'
|
2
|
-
|
3
1
|
Gem::Specification.new do |s|
|
4
2
|
s.name = 'saoshyant'
|
5
|
-
s.version = '1.
|
3
|
+
s.version = '1.1'
|
6
4
|
s.date = '2020-02-10'
|
7
5
|
s.summary = "Handle Rails Exception Apis"
|
8
6
|
s.description = "when exceptoin raised we dont want see it in ugly and red display, saoshyant present it in json response"
|
data/spec/saoshyant_test.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
include Saoshyant
|
2
3
|
|
3
4
|
describe Saoshyant do
|
4
5
|
describe 'JsonExceptionHandeler' do
|
5
6
|
it 'expect get error for invalid code status' do
|
6
|
-
expect{
|
7
|
+
expect{ saoshyant_option(NameError, '200', false) }.to raise_error(RuntimeError)
|
7
8
|
end
|
8
9
|
|
9
10
|
it 'expect get error for invalid log status' do
|
10
|
-
expect{
|
11
|
+
expect{ saoshyant_option(NameError, 203, 'true') }.to raise_error(RuntimeError)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saoshyant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Majid Imanzade
|
@@ -63,8 +63,8 @@ files:
|
|
63
63
|
- ".gitignore"
|
64
64
|
- ".rspec"
|
65
65
|
- Gemfile
|
66
|
+
- lib/exception_handler.rb
|
66
67
|
- lib/exception_logger.rb
|
67
|
-
- lib/json_exception_handeler.rb
|
68
68
|
- lib/saoshyant.rb
|
69
69
|
- saoshyant.gemspec
|
70
70
|
- spec/saoshyant_test.rb
|