From 5ccb12706ac217a7f0b07e4c73ca870bb70fabdf Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 19 Dec 2022 21:24:40 +0200 Subject: [PATCH] Guard against build type being missing --- source/builder.cpp | 8 ++++++++ source/builder.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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 &); -- 2.43.0