eh 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +3 -3
- data/backlog +78 -0
- data/lib/eh/eh.rb +1 -1
- data/lib/eh/version.rb +1 -1
- data/spec/eh_spec.rb +25 -1
- metadata +5 -4
    
        data/README.md
    CHANGED
    
    | @@ -99,11 +99,11 @@ retry! - Execute block, re-raise exceptions, retry | |
| 99 99 |  | 
| 100 100 | 
             
            Exception filters:
         | 
| 101 101 |  | 
| 102 | 
            -
            When :exception_filter is provided to retry!(), only the exceptions in the filter are retried. If retry fails, all exceptions are re-raised.
         | 
| 102 | 
            +
            When :exception_filter is provided to retry!(), only the exceptions in the filter are retried. If retry fails, *all* exceptions are re-raised.
         | 
| 103 103 |  | 
| 104 | 
            -
            When :exception_filter is provided to retry(), only the exceptions in the filter are retried. If retry fails | 
| 104 | 
            +
            When :exception_filter is provided to retry(), only the exceptions in the filter are retried. If retry fails, exceptions are not re-raised.
         | 
| 105 105 |  | 
| 106 | 
            -
            When :exception_filter is provided to run!(), only the exceptions in the filter are logged, if a logger is provided.  | 
| 106 | 
            +
            When :exception_filter is provided to run!(), only the exceptions in the filter are logged, if a logger is provided. Filtered exceptions are *not* re-raised.
         | 
| 107 107 |  | 
| 108 108 | 
             
            When :exception_filter is provided to run(), only the exceptions in the filter are logged, if a logger is provided. Exceptions are not re-raised.
         | 
| 109 109 |  | 
    
        data/backlog
    ADDED
    
    | @@ -0,0 +1,78 @@ | |
| 1 | 
            +
            class Main
         | 
| 2 | 
            +
              def initialize
         | 
| 3 | 
            +
                EH::run!(:message=> "constructor should not fail!", :logger => MyLogger.new, :handlers => ImportantErrorHandler.new) do
         | 
| 4 | 
            +
                  some_bugg_initialzation
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
             | 
| 10 | 
            +
            class TestMe
         | 
| 11 | 
            +
              def something
         | 
| 12 | 
            +
                EH::push(:context => "super important")
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                EH::retry!() do
         | 
| 15 | 
            +
                  some_buggy_code
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                EH::pop(:context)
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            def easy_to_use
         | 
| 23 | 
            +
              EH::in_order_to({:do => "something",
         | 
| 24 | 
            +
                               :given_that => "some state",
         | 
| 25 | 
            +
                               :note => "i am doing X with #{y}",
         | 
| 26 | 
            +
                               :error_handler => {:log_to => MyLogger.bnew, :mail_to => "helpme.com"}}) do
         | 
| 27 | 
            +
                code_a
         | 
| 28 | 
            +
                code_b
         | 
| 29 | 
            +
                code_c
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            class MySystemApiBoundary
         | 
| 34 | 
            +
              def talk_to_another_system(system, message)
         | 
| 35 | 
            +
                pkg = EH::package_context
         | 
| 36 | 
            +
                message["in_reference_to"] = pkg
         | 
| 37 | 
            +
                system.api_method(message)
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
             | 
| 42 | 
            +
             | 
| 43 | 
            +
             | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
            ... then package across system boundaries
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            class ContextDic..
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            module EH
         | 
| 52 | 
            +
              class EH
         | 
| 53 | 
            +
                def self.handle(context, e, env)
         | 
| 54 | 
            +
                  contexts[context].handle(e, env, context_stack)
         | 
| 55 | 
            +
                end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                def self.run(context) do
         | 
| 58 | 
            +
                  ?? << context
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  yield
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  >>
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
            end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
             | 
| 68 | 
            +
              complex_reg_task_abc do
         | 
| 69 | 
            +
                myabc
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
             | 
| 73 | 
            +
             | 
| 74 | 
            +
             | 
| 75 | 
            +
            EH::in_order_to({:do => "fullfil domain order",
         | 
| 76 | 
            +
                             :given_that => "account deos not exist" ... ).remember("i am creationg an account using #{blah}").and_if_something_goes_wrong(:mailmeat => "a@me.com") do
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            end
         | 
    
        data/lib/eh/eh.rb
    CHANGED
    
    | @@ -78,7 +78,7 @@ module ErrorHandler | |
| 78 78 | 
             
                  EH::handle(opts[:handlers], e, msg) if not opts[:handlers].nil?
         | 
| 79 79 |  | 
| 80 80 | 
             
                  raise e if opts.nil? == false and opts[:exception_filter] and not opts[:exception_filter].include? e.class
         | 
| 81 | 
            -
                  raise e
         | 
| 81 | 
            +
                  raise e if opts.nil? == true or opts[:exception_filter].nil? == true or opts[:exception_filter] == []
         | 
| 82 82 | 
             
                end
         | 
| 83 83 |  | 
| 84 84 | 
             
                def self.run(options, &block)
         | 
    
        data/lib/eh/version.rb
    CHANGED
    
    
    
        data/spec/eh_spec.rb
    CHANGED
    
    | @@ -97,7 +97,7 @@ describe ErrorHandler do | |
| 97 97 | 
             
                end
         | 
| 98 98 |  | 
| 99 99 | 
             
                describe "run!" do
         | 
| 100 | 
            -
                  it "should re-raise all exceptions if asked to" do
         | 
| 100 | 
            +
                  it "should re-raise all exceptions if asked to (no options provided)" do
         | 
| 101 101 | 
             
                    begin
         | 
| 102 102 | 
             
                      exception = nil
         | 
| 103 103 | 
             
                      EH::run!(nil) do
         | 
| @@ -109,6 +109,30 @@ describe ErrorHandler do | |
| 109 109 | 
             
                    exception.class.should == RuntimeError
         | 
| 110 110 | 
             
                  end
         | 
| 111 111 |  | 
| 112 | 
            +
                  it "should re-raise all exceptions if asked to (no exception filter provided)" do
         | 
| 113 | 
            +
                    begin
         | 
| 114 | 
            +
                      exception = nil
         | 
| 115 | 
            +
                      EH::run!(:exception_filer => nil) do
         | 
| 116 | 
            +
                        raise RuntimeError
         | 
| 117 | 
            +
                      end
         | 
| 118 | 
            +
                    rescue => e
         | 
| 119 | 
            +
                      exception = e
         | 
| 120 | 
            +
                    end
         | 
| 121 | 
            +
                    exception.class.should == RuntimeError
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
                  it "should re-raise all exceptions if asked to (empty exception filter provided)" do
         | 
| 125 | 
            +
                    begin
         | 
| 126 | 
            +
                      exception = nil
         | 
| 127 | 
            +
                      EH::run!(:exception_filter => []) do
         | 
| 128 | 
            +
                        raise RuntimeError
         | 
| 129 | 
            +
                      end
         | 
| 130 | 
            +
                    rescue => e
         | 
| 131 | 
            +
                      exception = e
         | 
| 132 | 
            +
                    end
         | 
| 133 | 
            +
                    exception.class.should == RuntimeError
         | 
| 134 | 
            +
                  end
         | 
| 135 | 
            +
             | 
| 112 136 | 
             
                  it "should not retry" do
         | 
| 113 137 | 
             
                    begin
         | 
| 114 138 | 
             
                      count = 0
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: eh
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 19
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 0
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.0. | 
| 9 | 
            +
              - 6
         | 
| 10 | 
            +
              version: 0.0.6
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Ernst van Graan, Wynand van Dyk
         | 
| @@ -15,7 +15,7 @@ autorequire: | |
| 15 15 | 
             
            bindir: bin
         | 
| 16 16 | 
             
            cert_chain: []
         | 
| 17 17 |  | 
| 18 | 
            -
            date: 2013-03- | 
| 18 | 
            +
            date: 2013-03-19 00:00:00 Z
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 21 21 | 
             
              name: bundler
         | 
| @@ -90,6 +90,7 @@ files: | |
| 90 90 | 
             
            - LICENSE.txt
         | 
| 91 91 | 
             
            - README.md
         | 
| 92 92 | 
             
            - Rakefile
         | 
| 93 | 
            +
            - backlog
         | 
| 93 94 | 
             
            - eh.gemspec
         | 
| 94 95 | 
             
            - lib/eh/eh.rb
         | 
| 95 96 | 
             
            - lib/eh/version.rb
         |