16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/twat/exceptions.rb', line 16
def with_handled_exceptions(opts)
begin
yield opts
rescue Usage
opts.usage
rescue NoSuchAccount
puts "No such account"
opts.usage
rescue NoDefaultAccount
puts "No default account configured."
rescue NoSuchCommand
puts "No such command"
opts.usage
rescue NoConfigFile
puts "No config file, create one with twat -a [user|nick]"
opts.usage
rescue InvalidSetOpt
puts "There is no such configurable option"
opts.usage
rescue RequiresOptVal
puts "--set must take an option=value pair as arguments"
rescue InvalidCredentials
puts "Invalid credentials, try reauthenticating with"
puts "twat -a #{opts[:account]}"
rescue ConfigVersionIncorrect
puts "Your config file is out of date. Run with --update-config to rememdy"
rescue InvalidBool
puts "Invalid value, valid values are #{Options::BOOL_VALID.join("|")}"
rescue InvalidInt
puts "Invalid value, must be an integer"
rescue Errno::ECONNRESET
puts "Connection was reset by third party."
rescue TweetTooLong
puts "Twitter enforces a maximum status length of 140 characters"
end
end
|