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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66199fb80537dd06a9236b278dbdc7271f4e87b7
4
- data.tar.gz: 8f84861696913444b27bef5e377ff327376cd49a
3
+ metadata.gz: bfa4001634396c528a1238575759bc5b9b3ce3d1
4
+ data.tar.gz: dad2046bc4afbbc025a79b8a4ba589649e2f4c65
5
5
  SHA512:
6
- metadata.gz: 49cf68fb9d6eb4bc06b3a91247285150f3af4173689a3bd5a7dee79af4811795e458dd3e3a6c392772ea0b44714e1c430d253730d9ef97f22957dc1b016d081c
7
- data.tar.gz: 96704b115326f518183ae6508129a5a2223c57cf36b8aa3f38549927c9e0a8752600ef79327086561dce15522eb29bdee025672e65cb291ea3f2afc915a11adf
6
+ metadata.gz: d94365966375c29f13be21f27cd0bdc6056331ca195671ccff37ca3e72fa62ab085242927bca2b76b67537decdef47d9ff3ae57790aea531079bbc3bed8ca6b5
7
+ data.tar.gz: cdc2089ef7797c4c268e7c57de845d6d80abba091c842ca6ee1b9e46e48d5f0e338f998b9c92860a9fd412b5abf5e727d57864ff09daa94715abd33d3e6dfa7c
@@ -0,0 +1,12 @@
1
+ # CHANGELOG
2
+
3
+ ## Unreleased
4
+
5
+ ## 1.0.1 - 2016.05.11
6
+
7
+ - Default to StandardError when error class is not provided
8
+ @teohm [#1](https://github.com/JuanitoFatas/active_error/pull/1)
9
+
10
+ ## 1.0.0 - 2016.05.10
11
+
12
+ Init Active Error.
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/[USERNAME]/active_error.
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JuanitoFatas/active_error.
29
56
 
30
57
  ## License
31
58
 
@@ -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/JuanitoFata/active_error"
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)/}) }
@@ -1,8 +1,15 @@
1
1
  require "active_error/version"
2
2
 
3
3
  module ActiveError
4
- def self.new(error, message = nil, backtrace: caller)
5
- exception = error.new(message)
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
@@ -1,3 +1,3 @@
1
1
  module ActiveError
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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.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-10 00:00:00.000000000 Z
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/JuanitoFata/active_error
33
+ homepage: https://github.com/JuanitoFatas/active_error
33
34
  licenses:
34
35
  - Apache 2.0
35
36
  metadata: {}