From 4362eb0dce36dc2966933c2c13d5f28ec83e31c2 Mon Sep 17 00:00:00 2001 From: Erik Pique Date: Mon, 17 Dec 2018 14:47:19 +0100 Subject: [PATCH] remove try catch --- .../Controllers/ConfigurationController.cs | 23 +++++++------------ .../Controllers/ConfigurationController.cs | 23 +++++++------------ 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/ServiceFabric/Linux/eShopOnServiceFabricApiGateWays/ApiGw_Base/Controllers/ConfigurationController.cs b/ServiceFabric/Linux/eShopOnServiceFabricApiGateWays/ApiGw_Base/Controllers/ConfigurationController.cs index 5d24f4895..f3d060ce1 100644 --- a/ServiceFabric/Linux/eShopOnServiceFabricApiGateWays/ApiGw_Base/Controllers/ConfigurationController.cs +++ b/ServiceFabric/Linux/eShopOnServiceFabricApiGateWays/ApiGw_Base/Controllers/ConfigurationController.cs @@ -24,25 +24,18 @@ namespace ApiGw_Base.Controllers private IActionResult ReadConfigurationFile(ConfigurationType configurationType, ConfigurationBffType configurationBffType) { - try + var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{configurationType}.Bff.{configurationBffType}.json"; + + using (var streamReader = new StreamReader(path, Encoding.UTF8)) { - var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{configurationType}.Bff.{configurationBffType}.json"; + var jsonString = streamReader.ReadToEnd(); - using (var streamReader = new StreamReader(path, Encoding.UTF8)) + if (string.IsNullOrWhiteSpace(jsonString)) { - var jsonString = streamReader.ReadToEnd(); - - if (string.IsNullOrWhiteSpace(jsonString)) - { - return BadRequest($"Configuration file 'configuration.{configurationType}.Bff.{configurationBffType}.json' not found"); - } - - return Ok(jsonString); + return BadRequest($"Configuration file 'configuration.{configurationType}.Bff.{configurationBffType}.json' not found"); } - } - catch (Exception exception) - { - return BadRequest(exception.Message); + + return Ok(jsonString); } } } diff --git a/ServiceFabric/Windows/eShopOnServiceFabricApiGateWays/eShopOnServiceFabricApiGW/ApiGw_Base/Controllers/ConfigurationController.cs b/ServiceFabric/Windows/eShopOnServiceFabricApiGateWays/eShopOnServiceFabricApiGW/ApiGw_Base/Controllers/ConfigurationController.cs index 5d24f4895..f3d060ce1 100644 --- a/ServiceFabric/Windows/eShopOnServiceFabricApiGateWays/eShopOnServiceFabricApiGW/ApiGw_Base/Controllers/ConfigurationController.cs +++ b/ServiceFabric/Windows/eShopOnServiceFabricApiGateWays/eShopOnServiceFabricApiGW/ApiGw_Base/Controllers/ConfigurationController.cs @@ -24,25 +24,18 @@ namespace ApiGw_Base.Controllers private IActionResult ReadConfigurationFile(ConfigurationType configurationType, ConfigurationBffType configurationBffType) { - try + var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{configurationType}.Bff.{configurationBffType}.json"; + + using (var streamReader = new StreamReader(path, Encoding.UTF8)) { - var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{configurationType}.Bff.{configurationBffType}.json"; + var jsonString = streamReader.ReadToEnd(); - using (var streamReader = new StreamReader(path, Encoding.UTF8)) + if (string.IsNullOrWhiteSpace(jsonString)) { - var jsonString = streamReader.ReadToEnd(); - - if (string.IsNullOrWhiteSpace(jsonString)) - { - return BadRequest($"Configuration file 'configuration.{configurationType}.Bff.{configurationBffType}.json' not found"); - } - - return Ok(jsonString); + return BadRequest($"Configuration file 'configuration.{configurationType}.Bff.{configurationBffType}.json' not found"); } - } - catch (Exception exception) - { - return BadRequest(exception.Message); + + return Ok(jsonString); } } }