From: Mikko Rasa Date: Mon, 19 Dec 2022 19:24:40 +0000 (+0200) Subject: Guard against build type being missing X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5ccb12706ac217a7f0b07e4c73ca870bb70fabdf;p=builder.git Guard against build type being missing --- diff --git a/source/builder.cpp b/source/builder.cpp index a49624d..46bc704 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -70,6 +71,13 @@ vector 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); diff --git a/source/builder.h b/source/builder.h index e6eb0ea..b7b0b78 100644 --- a/source/builder.h +++ b/source/builder.h @@ -73,7 +73,7 @@ public: const Architecture &get_native_arch() const { return native_arch; } void set_build_type(const std::string &); std::vector 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 &);