error_nande 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +1 -0
- data/error_nande.gemspec +29 -0
- data/lib/error_nande.rb +34 -0
- data/lib/error_nande/version.rb +3 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 389b91b5c03e073a15b80370fa1f0fba2346406f
|
4
|
+
data.tar.gz: eed55d1fb8f98f81a8d134d8a05b0fe985957a14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4eff215d8571d25fe79267732d8b153101ed8cb597e4dd78e06ba7f1e5f9bd3a6c4d6e6b836be929b0dd60ea44c0defba2ebe73f4fe467c517c4b63ef6cff980
|
7
|
+
data.tar.gz: 1b08c82a8d640acc3d47eaf48eab5059dc4e2422576d5f56b65ffc0db99324aafab4afedc068ba8f5c0bf4d1c42b4e3fc5ac5ea8b4ce54a305a46a0926978881
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright 2016 Keiichiro Nagano
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# ErrorNande
|
2
|
+
|
3
|
+
アイエエエエ! エラー!? エラーナンデ!?
|
4
|
+
|
5
|
+
例外を整形して文字列1行で返す
|
6
|
+
|
7
|
+
全てを1行に納めているので、ログに出力したとき、grep結果に全ての情報が含まれているため、エラーがナンデか追いやすい
|
8
|
+
|
9
|
+
|
10
|
+
文字列には、クラス名、メッセージ、バックトレースの1行目が含まれる
|
11
|
+
|
12
|
+
```
|
13
|
+
> ErrorNande.nande(error1)
|
14
|
+
=> "#<ErrorClass: error message> at path/to/code.rb:42:in `func'"
|
15
|
+
```
|
16
|
+
|
17
|
+
例外に re-raise による `cause` が付いている場合、再帰的に文字列化される
|
18
|
+
|
19
|
+
```
|
20
|
+
> ErrorNande.nande(error2)
|
21
|
+
=> "#<ErrorClass1: error message1> at path/to/code1.rb:42:in `func1' (cause #<ErrorClass2: error message2> at path/to/code2.rb:242:in `func2') (cause #<ErrorClass3: error message3> at path/to/code3.rb:242:in `func3')"
|
22
|
+
```
|
23
|
+
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
Add this line to your application's Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'error_nande'
|
31
|
+
```
|
32
|
+
|
33
|
+
And then execute:
|
34
|
+
|
35
|
+
$ bundle
|
36
|
+
|
37
|
+
Or install it yourself as:
|
38
|
+
|
39
|
+
$ gem install error_nande
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
1. Fork it ( https://github.com/knagano/error_nande/fork )
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/error_nande.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'error_nande/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "error_nande"
|
8
|
+
spec.version = ErrorNande::VERSION
|
9
|
+
spec.authors = ["Keiichiro Nagano"]
|
10
|
+
spec.email = ["knagano@CPAN.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{アイエエエエ! エラー!? エラーナンデ!?}
|
13
|
+
spec.description = %q{例外を整形して文字列1行で返す}
|
14
|
+
spec.homepage = %q{https://github.com/knagano/error_nande}
|
15
|
+
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
27
|
+
#spec.add_development_dependency "rails" # NOTE: uncomment to run spec
|
28
|
+
|
29
|
+
end
|
data/lib/error_nande.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "error_nande/version"
|
2
|
+
|
3
|
+
module ErrorNande
|
4
|
+
def self.nande(error)
|
5
|
+
summary = "#{error.inspect} at #{compact_backtrace(error)}"
|
6
|
+
while error = error.cause
|
7
|
+
summary << " (cause #{error.inspect} at #{compact_backtrace(error)})"
|
8
|
+
end
|
9
|
+
summary
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
alias_method :summary, :nande
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.compact_backtrace(error)
|
17
|
+
return "(toplevel)" unless error.backtrace
|
18
|
+
self.backtrace_cleaner.clean(error.backtrace, :no_silencers).first
|
19
|
+
end
|
20
|
+
|
21
|
+
class NullBacktraceCleaner
|
22
|
+
def clean(backtrace, *rest)
|
23
|
+
backtrace
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.backtrace_cleaner
|
28
|
+
if defined?(::Rails) && ::Rails.backtrace_cleaner
|
29
|
+
::Rails.backtrace_cleaner
|
30
|
+
else
|
31
|
+
NullBacktraceCleaner.new
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: error_nande
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keiichiro Nagano
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
description: 例外を整形して文字列1行で返す
|
56
|
+
email:
|
57
|
+
- knagano@CPAN.org
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- CHANGELOG.md
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- error_nande.gemspec
|
70
|
+
- lib/error_nande.rb
|
71
|
+
- lib/error_nande/version.rb
|
72
|
+
homepage: https://github.com/knagano/error_nande
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.5.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: アイエエエエ! エラー!? エラーナンデ!?
|
96
|
+
test_files: []
|