incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core] Core: Added nice error messages when user try to run server with unknown driver or drivers configuration is missing
Date Thu, 15 Sep 2011 08:58:33 GMT
From: Michal Fojtik <mfojtik@redhat.com>


Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/drivers.rb |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/server/lib/drivers.rb b/server/lib/drivers.rb
index 722e1d7..7e3af07 100644
--- a/server/lib/drivers.rb
+++ b/server/lib/drivers.rb
@@ -37,6 +37,10 @@ module Deltacloud
         Dir[File.join(File::dirname(__FILE__), '..', 'config', 'drivers', '*.yaml')].each
do |driver_file|
           Thread::current[:drivers].merge!(YAML::load(File::read(driver_file)))
         end
+        if Thread::current[:drivers].empty?
+          raise "You need to install drivers before starting Deltacloud API"
+          exit(1)
+        end
       end
       Thread::current[:drivers]
     end
@@ -64,7 +68,11 @@ module Deltacloud
     end
 
     def driver
-      require driver_source_name
+      begin
+        require driver_source_name
+      rescue LoadError
+        raise "Driver name not recognized: #{driver_symbol}"
+      end
       @driver ||= driver_class.new
     end
   end
-- 
1.7.4.1


Mime
View raw message