Permalink
Browse files

Kernel#abort does three things:

1. It sets the exit status to 1
2. It prints its argument to stderr
3. It terminates the process

So

  abort "unable to launch missiles :("

is equivalent to:

  $stderr.puts "unable to launch missiles :("
  exit(1)

When printing an error message, it's often a good idea to use the word "error". Users are familiar with that. Also try not to use generic terms like "input" and "data", be specific. When possible, give the user a hint about what they did wrong. For example:

  Permission error

Might be rephrased as:

  Error: Unable to start server on 366
  Are you root?
  • Loading branch information...
quackingduck committed Nov 22, 2009
1 parent 0f25b0d commit 294d976e05e611c60afc0af73ed83e8e5f860bda
Showing with 4 additions and 4 deletions.
  1. +4 −4 gistory.rb
View
@@ -51,10 +51,10 @@ def get_commits(repo, file_name, branch)
repo = Repo.new(File.expand_path(repo_dir))
puts "Loading commits..."
commits = get_commits(repo, file_name, branch)
if commits.empty?
puts "No commits found for supplied data; pleast check the data you supplied and try again."
exit
end
abort %(Error: Couldn't find any commits.
Are you sure this is a git repo and the file exists?) if commits.empty?
puts "Loaded commits"
require 'sinatra'

0 comments on commit 294d976

Please sign in to comment.