Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made error messages for no accounts and no active account work.

  • Loading branch information...
commit dbc9e57d0a66ee585893b0b5955078575effc616 1 parent 71091f9
@jnunemaker jnunemaker authored
Showing with 10 additions and 3 deletions.
  1. +1 −1  TODO.txt
  2. +9 −2 lib/twitter/cli/helpers.rb
View
2  TODO.txt
@@ -1,4 +1,4 @@
+* if removing the current account, set a new one
* import from .twitter
-* check if there is a current account before any methods that use that account
* add timeout so it doesn't hang forever like it does now if twitter is down
* add progress indicator for timeline and replies as posting has for more visual indication that work is happening
View
11 lib/twitter/cli/helpers.rb
@@ -1,6 +1,9 @@
module Twitter
module CLI
module Helpers
+ class NoActiveAccount < StandardError; end
+ class NoAccounts < StandardError; end
+
def output_tweets(collection, options={})
options.reverse_merge!({
:cache => false,
@@ -31,8 +34,8 @@ def base(username=current_account.username, password=current_account.password)
end
def current_account
- @current_account ||= Account.active
- exit('No current account.') if @current_account.blank?
+ @current_account ||= Account.active
+ raise Account.count == 0 ? NoAccounts : NoActiveAccount if @current_account.blank?
@current_account
end
@@ -46,6 +49,10 @@ def do_work(&block)
say("Twitter is unavailable right now. Try again later.")
rescue Twitter::CantConnect => msg
say("Can't connect to twitter because: #{msg}")
+ rescue Twitter::CLI::Helpers::NoActiveAccount
+ say("You have not set an active account. Use 'twitter change' to set one now.")
+ rescue Twitter::CLI::Helpers::NoAccounts
+ say("You have not created any accounts. Use 'twitter add' to create one now.")
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.