]> git.tdb.fi Git - builder.git/blobdiff - source/builder.cpp
Exception handling fixes
[builder.git] / source / builder.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;
 }