Alessio Caiazza avatar Alessio Caiazza committed d01e9d5

better error handling

Comments (0)

Files changed (4)

 require 'dependency_wiring/thor_app'
 
 
-DependencyWiring::ThorApp.start
+begin
+  DependencyWiring::ThorApp.start
+rescue Exception => e
+  STDERR.puts e
+end

lib/dependency_wiring/git.rb

     
     def clone
       ret = sh_with_code("git clone #{git_opts} #{@src} .")
-      raise("Cannot clone #{@src} into #{@dest}! Output: #{ret[0]}") if ret[1] != 0
+      raise("GIT: Cannot clone #{@src} into #{@dest}! Output: #{ret[0]}") if ret[1] != 0
       rev = git_revision
       update if (rev != @opts[:branc] && rev != default_opts[:rev])
     end
 
     def pull
       ret = sh_with_code("git fetch #{@src}")
-      raise("Cannot fetch #{@dest}! Output: #{ret[0]}") if ret[1] != 0
+      raise("GIT: Cannot fetch #{@dest}! Output: #{ret[0]}") if ret[1] != 0
     end
 
     def update
       ret = sh_with_code("git checkout #{git_revision}")
       if ret[1] != 0
-        raise("Cannot update #{@dest} to #{git_revision}! Output: #{ret[0]}") 
+        raise("GIT: Cannot update #{@dest} to #{git_revision}! Output: #{ret[0]}") 
       end
     end    
 

lib/dependency_wiring/mercurial.rb

     
     def clone
       ret = sh_with_code("hg clone #{hg_opts} #{@src} .")
-      raise("Cannot clone #{@src} into #{@dest}! Output: #{ret[0]}") if ret[1] != 0
+      raise("HG: Cannot clone #{@src} into #{@dest}! Output: #{ret[0]}") if ret[1] != 0
     end
 
     def pull
       ret = sh_with_code("hg pull #{hg_opts} #{@src}")
-      raise("Cannot pull #{@dest}! Output: #{ret[0]}") if ret[1] != 0
+      raise("HG: Cannot pull #{@dest}! Output: #{ret[0]}") if ret[1] != 0
     end
 
     def update
       ret = sh_with_code("hg update -C #{hg_revision}")
       if ret[1] != 0
-        raise("Cannot update #{@dest} to #{hg_revision}! Output: #{ret[0]}") 
+        raise("HG: Cannot update #{@dest} to #{hg_revision}! Output: #{ret[0]}") 
       end
     end    
 

lib/dependency_wiring/scm.rb

         end
       else
         super()
-        clone
+        begin
+          clone
+        rescue Exception => e 
+          Dir.delete(@dest) if File.exists?(@dest) && File.directory?(@dest)
+          raise e
+        end      
       end
     end
   end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.