]> git.tdb.fi Git - builder.git/commitdiff
Guard against build type being missing
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 19:24:40 +0000 (21:24 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 19:24:40 +0000 (21:24 +0200)
source/builder.cpp
source/builder.h

index a49624d13201d6eb8d9112f6653c1546909cf85f..46bc704140690a1678af3f3f8f4f3b06ed218818 100644 (file)
@@ -1,4 +1,5 @@
 #include <set>
+#include <msp/core/except.h>
 #include <msp/core/maputils.h>
 #include <msp/datafile/parser.h>
 #include <msp/fs/dir.h>
@@ -70,6 +71,13 @@ vector<string> Builder::get_build_types() const
        return keys;
 }
 
+const BuildType &Builder::get_build_type() const
+{
+       if(!build_type)
+               throw invalid_state("no build type");
+       return *build_type;
+}
+
 void Builder::set_build_type(const string &name)
 {
        build_type = &get_item(build_types, name);
index e6eb0ea5c2843b3b813dbcc497a7379dfa40b71d..b7b0b78b407e4445a1f354b74e08d7571f3a9aaf 100644 (file)
@@ -73,7 +73,7 @@ public:
        const Architecture &get_native_arch() const { return native_arch; }
        void set_build_type(const std::string &);
        std::vector<std::string> get_build_types() const;
-       const BuildType &get_build_type() const { return *build_type; }
+       const BuildType &get_build_type() const;
        BuildGraph &get_build_graph() { return build_graph; }
        void set_prefix(const Msp::FS::Path &);
        void set_temp_directory(const Msp::FS::Path &);