lib/grepg/parser.rb in grepg-0.0.5 vs lib/grepg/parser.rb in grepg-0.0.6
- old
+ new
@@ -1,9 +1,8 @@
require 'trollop'
require 'rest-client'
require 'yaml'
-require_relative 'version'
# This class parses commandline arguments
module GrepPage
class Parser
def initialize(args)
@@ -98,27 +97,30 @@
puts headers.join(", ")
begin
topics = get_all_topics(user)
rescue RestClient::ResourceNotFound
- puts "That username does not exist"
- raise "Unable to find user"
+ raise GrepPage::NotFoundError, "Unable to find user"
end
topic = filter_topics(topics, topic)
if topic.nil? || topic.empty?
puts "Can't find that topic. Choose one of the following"
puts topics.map{|t| t[:name]}
- raise "Unable to find topic"
+ raise GrepPage::NotFoundError, "Unable to find topic"
end
cheats = get_cheats(user, topic[:id])
cheats = filter_cheats(cheats, search_term) if search_term
GrepPage::Formatter.cheat_rows(cheats, search_term, colorize)
end
def run!
- process_args(@user, @topic, @search_term, @colorize)
+ begin
+ process_args(@user, @topic, @search_term, @colorize)
+ rescue GrepPage::NotFoundError => ex
+ abort "Error: #{ex.message}"
+ end
end
end
end