Skip to content

Commit

Permalink
Fix sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMarechal25 committed Jun 3, 2024
1 parent 2c3684a commit 9ff7e73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/api/include/antares/api/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
#pragma once
#include "SimulationResults.h"

namespace Antares::API {
namespace Antares::API
{
/**
* @brief The PerformSimulation function is used to perform a simulation.
* @param study_path The path to the study to be simulated.
* @return SimulationResults object which contains the results of the simulation.
* @exception noexcept This function does not throw exceptions.
*/
SimulationResults PerformSimulation(std::filesystem::path study_path) noexcept;
}
SimulationResults PerformSimulation(const std::filesystem::path& study_path) noexcept;
} // namespace Antares::API
24 changes: 13 additions & 11 deletions src/api/solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@
*/

#include <antares/api/solver.h>
#include "private/API.h"
#include "antares/study-loader/IStudyLoader.h"
#include "antares/file-tree-study-loader/FileTreeStudyLoader.h"
#include "antares/study-loader/IStudyLoader.h"

namespace Antares::API {
#include "private/API.h"

SimulationResults PerformSimulation(std::filesystem::path study_path) noexcept
namespace Antares::API
{
try {

SimulationResults PerformSimulation(const std::filesystem::path& study_path) noexcept
{
try
{
APIInternal api;
FileTreeStudyLoader study_loader(study_path);
return api.run(study_loader);
} catch (const std::exception& e) {
}
catch (const std::exception& e)
{
Antares::API::Error err{.reason = e.what()};
return
SimulationResults{
.simulationPath = study_path, .antares_problems{}, .error = err
};
return SimulationResults{.simulationPath = study_path, .antares_problems{}, .error = err};
}
}

}
} // namespace Antares::API

0 comments on commit 9ff7e73

Please sign in to comment.