[logaling-commit] logaling/logaling-command [master] Catch exception when project not found

Back to archive index

null+****@clear***** null+****@clear*****
Tue Jun 26 15:06:42 JST 2012


SUZUKI Miho	2012-06-26 15:06:42 +0900 (Tue, 26 Jun 2012)

  New Revision: 446603eebd3af5243faf6c01f32b93eed9f665aa
  https://github.com/logaling/logaling-command/commit/446603eebd3af5243faf6c01f32b93eed9f665aa

  Merged 7228757: Merge pull request #60 from logaling/refactor-structure

  Log:
    Catch exception when project not found

  Modified files:
    lib/logaling/command/application.rb

  Modified: lib/logaling/command/application.rb (+12 -0)
===================================================================
--- lib/logaling/command/application.rb    2012-06-26 14:13:51 +0900 (663bca7)
+++ lib/logaling/command/application.rb    2012-06-26 15:06:42 +0900 (b5293cb)
@@ -175,6 +175,7 @@ module Logaling::Command
       @config.check_required_option(required_options)
       check_logaling_home_exists
       project =****@repos*****_project(@config.glossary)
+      raise Logaling::ProjectNotFound unless project
       glossary = project.find_glossary(@config.source_language, @config.target_language)
       if glossary.bilingual_pair_exists?(source_term, target_term)
         raise Logaling::TermError, "term '#{source_term}: #{target_term}' already exists in '#{@config.glossary}'"
@@ -185,6 +186,8 @@ module Logaling::Command
       say e.message
     rescue Logaling::GlossaryNotFound => e
       say "Try 'loga new or register' first."
+    rescue Logaling::ProjectNotFound
+      say "glossary <#{@config.glossary}> not found"
     end
 
     desc 'delete [SOURCE TERM] [TARGET TERM(optional)] [--force(optional)]', 'Delete term.'
@@ -198,6 +201,7 @@ module Logaling::Command
       @config.check_required_option(required_options)
       check_logaling_home_exists
       project =****@repos*****_project(@config.glossary)
+      raise Logaling::ProjectNotFound unless project
       glossary = project.find_glossary(@config.source_language, @config.target_language)
 
       if target_term
@@ -209,6 +213,8 @@ module Logaling::Command
       say e.message
     rescue Logaling::GlossaryNotFound => e
       say "Try 'loga new or register' first."
+    rescue Logaling::ProjectNotFound
+      say "glossary <#{@config.glossary}> not found"
     end
 
     desc 'update [SOURCE TERM] [TARGET TERM] [NEW TARGET TERM] [NOTE(optional)]', 'Update term.'
@@ -221,6 +227,7 @@ module Logaling::Command
       @config.check_required_option(required_options)
       check_logaling_home_exists
       project =****@repos*****_project(@config.glossary)
+      raise Logaling::ProjectNotFound unless project
       glossary = project.find_glossary(@config.source_language, @config.target_language)
       if glossary.bilingual_pair_exists?(source_term, new_target_term, note)
         raise Logaling::TermError, "term '#{source_term}: #{new_target_term}' already exists in '#{@config.glossary}'"
@@ -231,6 +238,8 @@ module Logaling::Command
       say e.message
     rescue Logaling::GlossaryNotFound => e
       say "Try 'loga new or register' first."
+    rescue Logaling::ProjectNotFound
+      say "glossary <#{@config.glossary}> not found"
     end
 
     desc 'lookup [TERM]', 'Lookup terms.'
@@ -293,6 +302,7 @@ module Logaling::Command
       @config.check_required_option(required_options)
       check_logaling_home_exists
       project =****@repos*****_project(@config.glossary)
+      raise Logaling::ProjectNotFound unless project
       glossary = project.find_glossary(@config.source_language, @config.target_language)
       terms = glossary.terms
       unless terms.empty?
@@ -308,6 +318,8 @@ module Logaling::Command
       end
     rescue Logaling::CommandFailed, Logaling::GlossaryDBNotFound => e
       say e.message
+    rescue Logaling::ProjectNotFound
+      say "glossary <#{@config.glossary}> not found"
     end
 
     desc 'list', 'Show glossary list.'
-------------- next part --------------
An HTML attachment was scrubbed...
下載 



More information about the logaling-commit mailing list
Back to archive index