]> git.tdb.fi Git - builder.git/commitdiff
Exception handling fixes
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Feb 2008 15:38:09 +0000 (15:38 +0000)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Feb 2008 15:38:09 +0000 (15:38 +0000)
source/builder.cpp
source/config.cpp

index 21e7dcdf629c4a97780059c5d1615cb12dca60b2..8bef2c6e5d7a67d5126d86fbfa53b1295f5eb482 100644 (file)
@@ -11,6 +11,7 @@ Distributed under the LGPL
 #include <msp/core/getopt.h>
 #include <msp/datafile/parser.h>
 #include <msp/io/buffered.h>
+#include <msp/io/except.h>
 #include <msp/io/file.h>
 #include <msp/path/utils.h>
 #include <msp/strings/formatter.h>
@@ -473,15 +474,22 @@ Loads the given build file.
 */
 int Builder::load_build_file(const Path &fn)
 {
-       IO::File inf(fn.str());
-       IO::Buffered in(inf);
+       try
+       {
+               IO::File inf(fn.str());
+               IO::Buffered in(inf);
 
-       if(verbose>=3)
-               cout<<"Reading "<<fn<<'\n';
+               if(verbose>=3)
+                       cout<<"Reading "<<fn<<'\n';
 
-       DataFile::Parser parser(in, fn.str());
-       Loader loader(*this, fn.subpath(0, fn.size()-1));
-       loader.load(parser);
+               DataFile::Parser parser(in, fn.str());
+               Loader loader(*this, fn.subpath(0, fn.size()-1));
+               loader.load(parser);
+       }
+       catch(const IO::FileNotFound &)
+       {
+               return -1;
+       }
 
        return 0;
 }
index c8e9aaa7e57623a9506c3e248c8e11a21d73b810..816ee1abb0ea26140625d9ec13dacc518dc4987a 100644 (file)
@@ -6,6 +6,7 @@ Distributed under the LGPL
 */
 
 #include <msp/core/except.h>
+#include <msp/io/except.h>
 #include <msp/io/file.h>
 #include <msp/io/print.h>
 #include <msp/path/utils.h>
@@ -68,7 +69,7 @@ void Config::select_last_profile()
                in.getline(profile);
                set_option("profile", profile);
        }
-       catch(const SystemError &)
+       catch(const IO::FileNotFound &)
        { }
 
        freeze_mtime=true;
@@ -88,13 +89,8 @@ void Config::select_profile(const string &profile)
 
        if(!package.get_builder().get_dry_run())
        {
-               try
-               {
-                       IO::File out((package.get_source()/".profile.cache").str().c_str());
-                       IO::print(out, "%s\n", profile);
-               }
-               catch(const SystemError &)
-               { }
+               IO::File out((package.get_source()/".profile.cache").str(), IO::M_WRITE);
+               IO::print(out, "%s\n", profile);
        }
 
        freeze_mtime=true;
@@ -184,15 +180,10 @@ void Config::save() const
        if(i!=options.end())
                fn=package.get_source()/(".options."+i->second.value+".cache");
 
-       try
-       {
-               IO::File out(fn.str());
+       IO::File out(fn.str(), IO::M_WRITE);
 
-               for(i=options.begin(); i!=options.end(); ++i)
-                       IO::print(out, "option \"%s\" \"%s\";\n", i->second.name, i->second.value);
-       }
-       catch(const SystemError &)
-       { }
+       for(i=options.begin(); i!=options.end(); ++i)
+               IO::print(out, "option \"%s\" \"%s\";\n", i->second.name, i->second.value);
 }
 
 bool Config::set_option(const string &opt, const string &val)