From 2375a936353490586771ff33858d205f3202f399 Mon Sep 17 00:00:00 2001 From: Julien Michel Date: Tue, 15 Dec 2009 17:36:56 +0100 Subject: [PATCH] BUG: Removing exception from constructor and moving it to the GetParameter() method, whose calls should be protected inside a try/catch block --- Code/Common/otbConfigurationFile.cxx | 5 ++++- Code/Common/otbConfigurationFile.h | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Code/Common/otbConfigurationFile.cxx b/Code/Common/otbConfigurationFile.cxx index 086ce45a56..e71e17d978 100644 --- a/Code/Common/otbConfigurationFile.cxx +++ b/Code/Common/otbConfigurationFile.cxx @@ -16,6 +16,7 @@ =========================================================================*/ #include "otbConfigurationFile.h" +#include "otbMacro.h" namespace otb { @@ -25,6 +26,8 @@ ConfigurationFile::Pointer ConfigurationFile::Instance = NULL; ConfigurationFile ::ConfigurationFile() { + m_OTBConfig = NULL; + std::string OTBBinDir(OTB_CONFIG); try { @@ -32,7 +35,7 @@ ConfigurationFile } catch (ConfigFile::file_not_found& e) { - itkExceptionMacro(<< "Error - File '" << e.filename << "' not found."); + otbMsgDebugMacro(<< "Error - File '" << e.filename << "' not found."); } } diff --git a/Code/Common/otbConfigurationFile.h b/Code/Common/otbConfigurationFile.h index 7572a2b0ff..616b747a81 100644 --- a/Code/Common/otbConfigurationFile.h +++ b/Code/Common/otbConfigurationFile.h @@ -57,7 +57,13 @@ namespace otb /** Get parameter*/ template T GetParameter(const std::string & key) const { - try + + if(m_OTBConfig == NULL) + { + itkExceptionMacro(<<"Configuration file not found."); + } + + try { return m_OTBConfig->read( key ); } -- GitLab