mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
fix rescue
This commit is contained in:
parent
ac2732d116
commit
002ec2175b
3 changed files with 20 additions and 21 deletions
|
@ -40,7 +40,7 @@ class Cli
|
||||||
@config.setup(options)
|
@config.setup(options)
|
||||||
|
|
||||||
puts I18n.t('form.set_config.valid').to_s.green
|
puts I18n.t('form.set_config.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #15: #{e}".red
|
puts "#{I18n.t('display.error')} #15: #{e}".red
|
||||||
exit 2
|
exit 2
|
||||||
end
|
end
|
||||||
|
@ -57,7 +57,7 @@ class Cli
|
||||||
load_config
|
load_config
|
||||||
|
|
||||||
puts I18n.t('form.setup_config.valid').to_s.green
|
puts I18n.t('form.setup_config.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #8: #{e}".red
|
puts "#{I18n.t('display.error')} #8: #{e}".red
|
||||||
exit 2
|
exit 2
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ class Cli
|
||||||
@config.setup_gpg_key(@password, gpg_key)
|
@config.setup_gpg_key(@password, gpg_key)
|
||||||
|
|
||||||
puts I18n.t('form.setup_gpg_key.valid').to_s.green
|
puts I18n.t('form.setup_gpg_key.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #8: #{e}".red
|
puts "#{I18n.t('display.error')} #8: #{e}".red
|
||||||
exit 2
|
exit 2
|
||||||
end
|
end
|
||||||
|
@ -94,8 +94,7 @@ class Cli
|
||||||
# Load config
|
# Load config
|
||||||
def load_config
|
def load_config
|
||||||
@config.load_config
|
@config.load_config
|
||||||
|
rescue => e
|
||||||
rescue Exception => e
|
|
||||||
puts "#{I18n.t('display.error')} #10: #{e}".red
|
puts "#{I18n.t('display.error')} #10: #{e}".red
|
||||||
exit 2
|
exit 2
|
||||||
end
|
end
|
||||||
|
@ -108,7 +107,7 @@ class Cli
|
||||||
end
|
end
|
||||||
|
|
||||||
@mpw.read_data
|
@mpw.read_data
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #11: #{e}".red
|
puts "#{I18n.t('display.error')} #11: #{e}".red
|
||||||
exit 2
|
exit 2
|
||||||
end
|
end
|
||||||
|
@ -340,7 +339,7 @@ class Cli
|
||||||
@mpw.write_data
|
@mpw.write_data
|
||||||
|
|
||||||
puts I18n.t('form.add_key.valid').to_s.green
|
puts I18n.t('form.add_key.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #13: #{e}".red
|
puts "#{I18n.t('display.error')} #13: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -351,7 +350,7 @@ class Cli
|
||||||
@mpw.write_data
|
@mpw.write_data
|
||||||
|
|
||||||
puts I18n.t('form.delete_key.valid').to_s.green
|
puts I18n.t('form.delete_key.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #15: #{e}".red
|
puts "#{I18n.t('display.error')} #15: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -400,7 +399,7 @@ class Cli
|
||||||
@mpw.write_data
|
@mpw.write_data
|
||||||
|
|
||||||
puts I18n.t('form.add_item.valid').to_s.green
|
puts I18n.t('form.add_item.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #13: #{e}".red
|
puts "#{I18n.t('display.error')} #13: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -426,7 +425,7 @@ class Cli
|
||||||
|
|
||||||
puts I18n.t('form.update_item.valid').to_s.green
|
puts I18n.t('form.update_item.valid').to_s.green
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #14: #{e}".red
|
puts "#{I18n.t('display.error')} #14: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -450,7 +449,7 @@ class Cli
|
||||||
|
|
||||||
puts I18n.t('form.delete_item.valid').to_s.green
|
puts I18n.t('form.delete_item.valid').to_s.green
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #16: #{e}".red
|
puts "#{I18n.t('display.error')} #16: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -468,7 +467,7 @@ class Cli
|
||||||
item = get_item(items)
|
item = get_item(items)
|
||||||
clipboard(item, clipboard)
|
clipboard(item, clipboard)
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #14: #{e}".red
|
puts "#{I18n.t('display.error')} #14: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -500,7 +499,7 @@ class Cli
|
||||||
File.open(file, 'w') { |f| f << data.to_yaml }
|
File.open(file, 'w') { |f| f << data.to_yaml }
|
||||||
|
|
||||||
puts I18n.t('form.export.valid', file: file).to_s.green
|
puts I18n.t('form.export.valid', file: file).to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #17: #{e}".red
|
puts "#{I18n.t('display.error')} #17: #{e}".red
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -528,7 +527,7 @@ class Cli
|
||||||
@mpw.write_data
|
@mpw.write_data
|
||||||
|
|
||||||
puts I18n.t('form.import.valid').to_s.green
|
puts I18n.t('form.import.valid').to_s.green
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
puts "#{I18n.t('display.error')} #18: #{e}".red
|
puts "#{I18n.t('display.error')} #18: #{e}".red
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Config
|
||||||
File.open(@config_file, 'w') do |file|
|
File.open(@config_file, 'w') do |file|
|
||||||
file << config.to_yaml
|
file << config.to_yaml
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.config.write')}\n#{e}"
|
raise "#{I18n.t('error.config.write')}\n#{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class Config
|
||||||
|
|
||||||
ctx = GPGME::Ctx.new
|
ctx = GPGME::Ctx.new
|
||||||
ctx.genkey(param, nil, nil)
|
ctx.genkey(param, nil, nil)
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.config.genkey_gpg.exception')}\n#{e}"
|
raise "#{I18n.t('error.config.genkey_gpg.exception')}\n#{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class Config
|
||||||
raise if @gpg_key.empty? || @wallet_dir.empty?
|
raise if @gpg_key.empty? || @wallet_dir.empty?
|
||||||
|
|
||||||
I18n.locale = @lang.to_sym
|
I18n.locale = @lang.to_sym
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.config.load')}\n#{e}"
|
raise "#{I18n.t('error.config.load')}\n#{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ class MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
add_key(@key) if @keys[@key].nil?
|
add_key(@key) if @keys[@key].nil?
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.mpw_file.read_data')}\n#{e}"
|
raise "#{I18n.t('error.mpw_file.read_data')}\n#{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ class MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
File.rename(tmp_file, @wallet_file)
|
File.rename(tmp_file, @wallet_file)
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
File.unlink(tmp_file) if File.exist?(tmp_file)
|
File.unlink(tmp_file) if File.exist?(tmp_file)
|
||||||
|
|
||||||
raise "#{I18n.t('error.mpw_file.write_data')}\n#{e}"
|
raise "#{I18n.t('error.mpw_file.write_data')}\n#{e}"
|
||||||
|
@ -343,7 +343,7 @@ class MPW
|
||||||
crypto = GPGME::Crypto.new(armor: true)
|
crypto = GPGME::Crypto.new(armor: true)
|
||||||
|
|
||||||
crypto.decrypt(data, password: @gpg_pass).read.force_encoding('utf-8')
|
crypto.decrypt(data, password: @gpg_pass).read.force_encoding('utf-8')
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}"
|
raise "#{I18n.t('error.gpg_file.decrypt')}\n#{e}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ class MPW
|
||||||
end
|
end
|
||||||
|
|
||||||
crypto.encrypt(data, recipients: recipients).read
|
crypto.encrypt(data, recipients: recipients).read
|
||||||
rescue Exception => e
|
rescue => e
|
||||||
raise "#{I18n.t('error.gpg_file.encrypt')}\n#{e}"
|
raise "#{I18n.t('error.gpg_file.encrypt')}\n#{e}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue