forked from aeolus-incubator/thor-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request aeolus-incubator#10 from cwolferh/exception_handling
Catch all exceptions at the top level (but don't bury them!)
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require 'aeolus_cli/main' | ||
AeolusCli::Main.start | ||
|
||
begin | ||
AeolusCli::Main.start | ||
rescue Exception => ex | ||
puts "Error: #{ex.message}" | ||
fname = "/tmp/aeolus-cli-trace-#{Process.pid}.log" | ||
the_stack_trace = ex.backtrace().join($/) | ||
begin | ||
# it is very unlikely writing to /tmp would fail, but | ||
# wrap this so we don't bury the original exception | ||
f = File.open(fname, "w") | ||
puts "For further debugging information, see #{fname}" | ||
f.puts the_stack_trace | ||
f.close | ||
rescue | ||
puts "Was unable to write to the following stack trace to #{fname}:" | ||
puts the_stack_trace | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Default terminal width we use for cucumber tests | ||
default: THOR_COLUMNS=118 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Feature: Exception Handling | ||
|
||
Scenario: Garbage URL Input | ||
When I run `aeolus provider list --conductor-url=http://444.444.444.444:444/api --username=test --password=test` | ||
Then the aeolus command should write the stack trace to file | ||
And the output should contain: | ||
""" | ||
Error: | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'aruba/api' | ||
|
||
Then /^the aeolus command should write the stack trace to file$/ do | ||
/For further debugging information, see (\/tmp\/aeolus-cli-trace-\d+.log)/ =~ | ||
all_output | ||
trace_filename = Regexp.last_match(1) | ||
|
||
# The last line in the stack trace file will look something like | ||
# ....../thor-cli/bin/aeolus:6:in `<main>' | ||
check_file_content(trace_filename, /bin\/aeolus:\d+:in `<main>/, true) | ||
end |