Add some more useful error messages in the common situations (file doesn't exist, isn't a sqlite db)
This commit is contained in:
parent
7e9e160f17
commit
58775f8e06
2 changed files with 16 additions and 4 deletions
|
@ -4,9 +4,19 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "cookie_
|
||||||
|
|
||||||
# TODO: Locate cookie dbs automatically
|
# TODO: Locate cookie dbs automatically
|
||||||
filename = ARGV.first
|
filename = ARGV.first
|
||||||
if filename
|
unless filename
|
||||||
extractor = CookieExtractor::BrowserDetector.new_extractor(filename)
|
|
||||||
puts extractor.extract.join("\n")
|
|
||||||
else
|
|
||||||
puts "Usage: cookie_extractor /path/to/cookies.sqlite"
|
puts "Usage: cookie_extractor /path/to/cookies.sqlite"
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
if File.exists?(filename)
|
||||||
|
begin
|
||||||
|
extractor = CookieExtractor::BrowserDetector.new_extractor(filename)
|
||||||
|
puts extractor.extract.join("\n")
|
||||||
|
rescue SQLite3::NotADatabaseException,
|
||||||
|
CookieExtractor::BrowserNotDetectedException
|
||||||
|
puts "Error: File '#{filename}' is not a Firefox or Chrome cookie database"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "Error: File '#{filename}' does not exist"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
module CookieExtractor
|
module CookieExtractor
|
||||||
|
class BrowserNotDetectedException < Exception; end
|
||||||
|
|
||||||
class BrowserDetector
|
class BrowserDetector
|
||||||
|
|
||||||
def self.new_extractor(db_filename)
|
def self.new_extractor(db_filename)
|
||||||
|
|
Loading…
Reference in a new issue