From f5e39866444356c5b28337f104c3afc3553f2fd0 Mon Sep 17 00:00:00 2001 From: Hayodea Hakol Date: Wed, 8 Jan 2025 11:46:59 -0400 Subject: [PATCH] DeviceSpec:parser: improve exception messages --- hcore/deviceManager/deviceSpecParser.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hcore/deviceManager/deviceSpecParser.cpp b/hcore/deviceManager/deviceSpecParser.cpp index 90f5d95..12d3f90 100644 --- a/hcore/deviceManager/deviceSpecParser.cpp +++ b/hcore/deviceManager/deviceSpecParser.cpp @@ -14,7 +14,9 @@ std::string DeviceManager::readDeviceFile(const std::string& filename) { std::ifstream file(filename); if (!file.is_open()) { - throw std::runtime_error("Could not open file: " + filename); + throw std::runtime_error( + std::string(__func__) + ": Couldn't open deviceSpec file: " + + filename); } std::string content( @@ -46,11 +48,15 @@ void DeviceManager::parseAllDeviceSpecs(void) &fclose); if (!input) { - throw std::runtime_error("Failed to open memory as file"); + throw std::runtime_error( + std::string(__func__) + ": Failed to fmemopen() a FILE* for " + "parsing device specs"); } deviceSpeclin = input.get(); if (deviceSpecpparse()) { - throw std::runtime_error("Failed to parse device specs"); + throw std::runtime_error( + std::string(__func__) + ": Failed to parse device specs. " + "Check specs for errors"); } }