diff --git a/Code/Common/otbConfigurationFile.cxx b/Code/Common/otbConfigurationFile.cxx index 086ce45a56fa8ca06c21916e5437c69925ea9474..e71e17d9784510b1984dbbd835d8826eac8e3f3b 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 7572a2b0ff5fda45ea74b593df5ebc58a54b669d..616b747a81bfb6433f6cbe4bf6069a345466c41b 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 ); }