entity-manager: writeJsonFiles: fix throw on mkdir
writeJsonFiles is fixed to not throw in case the directory cannot be
created and instead use the overload with std::error_code to relay the
error to the caller instead.
Discovered the issue in unit testing:
```
C++ exception with description "filesystem error: cannot create directory: Permission denied [/var/configuration/]" thrown in the test body.
```
Tested: Inspection only.
Change-Id: I4c1c09cad5a560e9db9f994579ff9af2b5280c00
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/configuration.cpp b/src/entity_manager/configuration.cpp
index 7532fc1..1e4ceac 100644
--- a/src/entity_manager/configuration.cpp
+++ b/src/entity_manager/configuration.cpp
@@ -186,7 +186,12 @@
return true;
}
- std::filesystem::create_directory(configurationOutDir);
+ std::error_code ec;
+ std::filesystem::create_directory(configurationOutDir, ec);
+ if (ec)
+ {
+ return false;
+ }
std::ofstream output(currentConfiguration);
if (!output.good())
{