added modules error msg

This commit is contained in:
Samuele Locatelli
2020-06-12 18:42:32 +02:00
parent 6d2ffff97b
commit e56a5daefc
@@ -13,6 +13,7 @@ using static CMS_CORE_Library.Models.DataStructures;
using static Thermo.Active.Config.ServerConfig;
using static Thermo.Active.Model.Constants;
using Thermo.Active.Model.DTOModels.Recipe;
using Thermo.Active.Utils;
namespace Thermo.Active.Controllers.WebApi
{
@@ -27,11 +28,17 @@ namespace Thermo.Active.Controllers.WebApi
// Try connection
CmsError libraryError = ncAdapter.Connect();
if (libraryError.errorCode != 0)
return NotFound();
{
ThermoActiveLogger.LogError($"NC Not connected! | GetCurrentModules | {libraryError.exception}");
return InternalServerError();
}
CmsError cmsError = ncAdapter.ReadModulesBlock(out Dictionary<int, DTOModulesBlock> currModules);
if (cmsError.IsError())
{
ThermoActiveLogger.LogError($"GetRecipeOverview error | {cmsError.exception}");
return BadRequest(cmsError.localizationKey);
}
return Ok(currModules);
}