active_error 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +28 -1
- data/active_error.gemspec +1 -1
- data/lib/active_error.rb +9 -2
- data/lib/active_error/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa4001634396c528a1238575759bc5b9b3ce3d1
|
4
|
+
data.tar.gz: dad2046bc4afbbc025a79b8a4ba589649e2f4c65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d94365966375c29f13be21f27cd0bdc6056331ca195671ccff37ca3e72fa62ab085242927bca2b76b67537decdef47d9ff3ae57790aea531079bbc3bed8ca6b5
|
7
|
+
data.tar.gz: cdc2089ef7797c4c268e7c57de845d6d80abba091c842ca6ee1b9e46e48d5f0e338f998b9c92860a9fd412b5abf5e727d57864ff09daa94715abd33d3e6dfa7c
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,11 +1,38 @@
|
|
1
1
|
# ActiveError
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/active_error.svg)](https://badge.fury.io/rb/active_error)
|
4
|
+
[![Build Status](https://travis-ci.org/JuanitoFatas/active_error.svg?branch=master)](https://travis-ci.org/JuanitoFatas/active_error)
|
5
|
+
|
6
|
+
Easily create an exception with backtrace.
|
7
|
+
|
3
8
|
## Usage
|
4
9
|
|
5
10
|
```ruby
|
6
11
|
ActiveError.new(StandardError, "error message")
|
12
|
+
ActiveError.new(StandardError, "error message", backtrace: caller)
|
13
|
+
|
14
|
+
# default error class is StandardError
|
15
|
+
ActiveError.new("error message")
|
16
|
+
ActiveError.new("error message", backtrace: caller)
|
7
17
|
```
|
8
18
|
|
19
|
+
## Why
|
20
|
+
|
21
|
+
Fix this common pattern:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
exception = StandardError.new("error message")
|
25
|
+
exception.set_backtrace(caller)
|
26
|
+
```
|
27
|
+
|
28
|
+
Should be in one-step:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
ActiveError.new(StandardError, "error message", backtrace: caller)
|
32
|
+
```
|
33
|
+
|
34
|
+
Enjoy :tada:
|
35
|
+
|
9
36
|
## Installation
|
10
37
|
|
11
38
|
Add this line to your application's Gemfile:
|
@@ -25,7 +52,7 @@ Or install it yourself as:
|
|
25
52
|
|
26
53
|
## Contributing
|
27
54
|
|
28
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/JuanitoFatas/active_error.
|
29
56
|
|
30
57
|
## License
|
31
58
|
|
data/active_error.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %(Create an exception has never been easier in Ruby!)
|
13
13
|
spec.description = spec.summary
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/JuanitoFatas/active_error"
|
15
15
|
spec.license = "Apache 2.0"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
data/lib/active_error.rb
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
require "active_error/version"
|
2
2
|
|
3
3
|
module ActiveError
|
4
|
-
def self.new(
|
5
|
-
|
4
|
+
def self.new(error_class_or_message = nil, message = nil, backtrace: caller)
|
5
|
+
if error_class_or_message.is_a? Class
|
6
|
+
error_class = error_class_or_message
|
7
|
+
else
|
8
|
+
error_class = StandardError
|
9
|
+
message = error_class_or_message.to_s
|
10
|
+
end
|
11
|
+
|
12
|
+
exception = error_class.new(message)
|
6
13
|
exception.set_backtrace(backtrace)
|
7
14
|
exception
|
8
15
|
end
|
data/lib/active_error/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanito Fatas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-05-
|
12
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Create an exception has never been easier in Ruby!
|
15
15
|
email:
|
@@ -22,6 +22,7 @@ files:
|
|
22
22
|
- ".gitignore"
|
23
23
|
- ".rspec"
|
24
24
|
- ".travis.yml"
|
25
|
+
- CHANGELOG.md
|
25
26
|
- Gemfile
|
26
27
|
- LICENSE.txt
|
27
28
|
- README.md
|
@@ -29,7 +30,7 @@ files:
|
|
29
30
|
- active_error.gemspec
|
30
31
|
- lib/active_error.rb
|
31
32
|
- lib/active_error/version.rb
|
32
|
-
homepage: https://github.com/
|
33
|
+
homepage: https://github.com/JuanitoFatas/active_error
|
33
34
|
licenses:
|
34
35
|
- Apache 2.0
|
35
36
|
metadata: {}
|