diff --git a/.gitignore b/.gitignore index d7d6930..df04aab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.vs/ /build/ /prefix/ /linux-build/ diff --git a/include/ifc/abstract-sgraph.hxx b/include/ifc/abstract-sgraph.hxx index 5a1e15b..52296b6 100644 --- a/include/ifc/abstract-sgraph.hxx +++ b/include/ifc/abstract-sgraph.hxx @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include @@ -3544,7 +3546,20 @@ namespace ifc { // -- exception type in case of an invalid partition name struct InvalidPartitionName { - std::string_view name; + explicit InvalidPartitionName(std::string_view partition_name) + { + partition_name = partition_name.substr(0, partition_name_buffer.size() - 1); + std::copy(partition_name.begin(), partition_name.end(), partition_name_buffer.begin()); + partition_name_buffer[partition_name.length()] = 0; + } + + const char* partition_name() const noexcept + { + return partition_name_buffer.data(); + } + + private: + std::array partition_name_buffer; }; // Retrieve a partition summary based on the partition's name. diff --git a/src/ifc-printer/main.cxx b/src/ifc-printer/main.cxx index 270ebdb..f8a644c 100644 --- a/src/ifc-printer/main.cxx +++ b/src/ifc-printer/main.cxx @@ -18,14 +18,18 @@ void translate_exception() { std::cerr << "ifc architecture mismatch\n"; } - catch(ifc::error_condition::UnexpectedVisitor& e) + catch (const ifc::InvalidPartitionName& e) + { + std::cerr << "invalid partition name: " << e.partition_name() << '\n'; + } + catch (ifc::error_condition::UnexpectedVisitor& e) { std::cerr << "visit unexpected " << e.category << ": " << e.sort << '\n'; } - catch (const char* message) + catch (const std::exception& e) { - std::cerr << "caught: " << message; + std::cerr << "caught std exception: " << e.what(); } catch (...) { diff --git a/src/ifc-reader/reader.cxx b/src/ifc-reader/reader.cxx index 96e7bfb..ff936af 100644 --- a/src/ifc-reader/reader.cxx +++ b/src/ifc-reader/reader.cxx @@ -9,8 +9,7 @@ namespace ifc { Reader::Reader(const ifc::InputIfc& ifc_) : ifc(ifc_) { - if (not ifc.header()) - throw "file not found"; + IFCASSERT(ifc.header()); read_table_of_contents(); }