saoshyant 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 485baa3c186fc7b8e07b473e9bd065cd8e1920ac1007d3724850f898245289fb
4
+ data.tar.gz: 77f6240f7aea6db393e7e45521d1120d90cd623e58a9f89de9f1618a3bf441b8
5
+ SHA512:
6
+ metadata.gz: 87d8930e77392ebadc6648975a42bee4076be78f1ed47a75f7435dfb52edf2be91210f3956f16ccc979c45f87a8fd8f584b219df1800fa708531a88c40df61fb
7
+ data.tar.gz: 8c23bf5fae6955ce874c4751448a8cd3a727292e413dc320a3724ab1655a10ff979eb7738f0fdb5dfdd87f71ee91a34e8b5a2a9558764f5bea8121c0ed5cd958
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ doc/
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+
2
+ source "http://rubygems.org"
3
+
4
+ gemspec
5
+
6
+ gem "rails"
@@ -0,0 +1,7 @@
1
+ module Saoshyant
2
+ class ExceptionLogger
3
+ def self.log(msg)
4
+ Logger.new("#{Rails.root}/log/saoshyant.log").debug msg
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ require 'rails'
2
+ require 'exception_logger'
3
+
4
+ module Saoshyant
5
+ extend ActiveSupport::Concern
6
+
7
+ DEFAULT_ERROR_CODE = 500
8
+ included do
9
+ rescue_from Exception, with: :render_exception
10
+ end
11
+
12
+ def render_exception exception
13
+ code = exception.respond_to?(:code) ? exception&.code : DEFAULT_ERROR_CODE
14
+ log = exception.respond_to?(:log)
15
+
16
+ Saoshyant::MajidLogger.log(exception.message) if log == true
17
+ render json: {:message => exception.message}, status: code
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ module Saoshyant
2
+ class Version
3
+ GEM_VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ # require 'version'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'saoshyant'
5
+ s.version = '0.0.1'
6
+ s.date = '2020-02-10'
7
+ s.summary = "Handle Rails Exception Apis"
8
+ s.description = "when exceptoin raised we dont want see it in ugly and red display, saoshyant present it in json response"
9
+ s.authors = ["Majid Imanzade"]
10
+ s.email = 'majidimanzade1@gmail.com'
11
+ s.homepage = 'https://rubygems.org/gems/saoshyant'
12
+ s.license = 'MIT'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.require_paths = ['lib']
16
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: saoshyant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Majid Imanzade
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: when exceptoin raised we dont want see it in ugly and red display, saoshyant
14
+ present it in json response
15
+ email: majidimanzade1@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - lib/exception_logger.rb
23
+ - lib/saoshyant.rb
24
+ - lib/version.rb
25
+ - saoshyant.gemspec
26
+ homepage: https://rubygems.org/gems/saoshyant
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.1.2
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Handle Rails Exception Apis
49
+ test_files: []