Skip to content

Commit

Permalink
Add cli/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoody committed Mar 31, 2015
1 parent 29779be commit dbb2063
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
3 changes: 2 additions & 1 deletion bin/run-loop
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env ruby
require 'run_loop/cli/cli'
require 'run_loop/cli/errors'
require 'run_loop/environment'

begin
RunLoop::CLI::Tool.start
exit 0
rescue RunLoop::ValidationError, Thor::RequiredArgumentMissingError, Thor::UndefinedCommandError => e
rescue RunLoop::CLI::ValidationError, Thor::RequiredArgumentMissingError, Thor::UndefinedCommandError => e
puts e.message
exit 64
rescue Thor::Error => e
Expand Down
3 changes: 1 addition & 2 deletions lib/run_loop/cli/cli.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'thor'
require 'run_loop'
require 'run_loop/cli/errors'
require 'run_loop/cli/instruments'

trap 'SIGINT' do
Expand All @@ -8,8 +9,6 @@
end

module RunLoop
class ValidationError < Thor::InvocationError
end

module CLI

Expand Down
11 changes: 11 additions & 0 deletions lib/run_loop/cli/errors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'thor'

module RunLoop
module CLI
class ValidationError < Thor::InvocationError
end

class NotImplementedError < Thor::InvocationError
end
end
end
1 change: 1 addition & 0 deletions lib/run_loop/cli/instruments.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'thor'
require 'run_loop'
require 'run_loop/cli/errors'

module RunLoop
module CLI
Expand Down
21 changes: 21 additions & 0 deletions spec/lib/bin/errors_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'run_loop/cli/errors'

describe RunLoop::CLI::ValidationError do

it 'can be used to raise an error' do
expect {
raise RunLoop::CLI::ValidationError, 'Hey!'
}.to raise_error
end

end

describe RunLoop::CLI::NotImplementedError do

it 'can be used to raise an error' do
expect {
raise RunLoop::CLI::NotImplementedError, 'Hey!'
}.to raise_error
end

end

0 comments on commit dbb2063

Please sign in to comment.