diff --git a/bin/run-loop b/bin/run-loop index 3a24379f..d6a1f425 100755 --- a/bin/run-loop +++ b/bin/run-loop @@ -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 diff --git a/lib/run_loop/cli/cli.rb b/lib/run_loop/cli/cli.rb index 89a8d794..6539c700 100644 --- a/lib/run_loop/cli/cli.rb +++ b/lib/run_loop/cli/cli.rb @@ -1,5 +1,6 @@ require 'thor' require 'run_loop' +require 'run_loop/cli/errors' require 'run_loop/cli/instruments' trap 'SIGINT' do @@ -8,8 +9,6 @@ end module RunLoop - class ValidationError < Thor::InvocationError - end module CLI diff --git a/lib/run_loop/cli/errors.rb b/lib/run_loop/cli/errors.rb new file mode 100644 index 00000000..0b78bc16 --- /dev/null +++ b/lib/run_loop/cli/errors.rb @@ -0,0 +1,11 @@ +require 'thor' + +module RunLoop + module CLI + class ValidationError < Thor::InvocationError + end + + class NotImplementedError < Thor::InvocationError + end + end +end diff --git a/lib/run_loop/cli/instruments.rb b/lib/run_loop/cli/instruments.rb index a5ec1483..15379bba 100644 --- a/lib/run_loop/cli/instruments.rb +++ b/lib/run_loop/cli/instruments.rb @@ -1,5 +1,6 @@ require 'thor' require 'run_loop' +require 'run_loop/cli/errors' module RunLoop module CLI diff --git a/spec/lib/bin/errors_spec.rb b/spec/lib/bin/errors_spec.rb new file mode 100644 index 00000000..cdcaba80 --- /dev/null +++ b/spec/lib/bin/errors_spec.rb @@ -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