Skip to content
Snippets Groups Projects
Commit e1bd1f33 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: OTB-638: get the error message from GDAL and add it to the itk::Exception message

parent 9781e275
No related branches found
No related tags found
No related merge requests found
......@@ -354,7 +354,8 @@ void GDALImageIO::Read(void* buffer)
0);
if (lCrGdal == CE_Failure)
{
itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName.c_str() << ".");
itkExceptionMacro(<< "Error while reading image (GDAL format) '"
<< m_FileName.c_str() << "' : " << CPLGetLastErrorMsg());
}
// Interpret index as color
std::streamoff cpt(0);
......@@ -424,7 +425,8 @@ void GDALImageIO::Read(void* buffer)
// Check if gdal call succeed
if (lCrGdal == CE_Failure)
{
itkExceptionMacro(<< "Error while reading image (GDAL format) " << m_FileName.c_str() << ".");
itkExceptionMacro(<< "Error while reading image (GDAL format) '"
<< m_FileName.c_str() << "' : " << CPLGetLastErrorMsg());
return;
}
//printDataBuffer(p, m_PxType->pixType, m_NbBands, lNbColumnsRegion*lNbLinesRegion);
......@@ -1340,7 +1342,8 @@ void GDALImageIO::Write(const void* buffer)
// Check if writing succeed
if (lCrGdal == CE_Failure)
{
itkExceptionMacro(<< "Error while writing image (GDAL format) " << m_FileName.c_str() << ".");
itkExceptionMacro(<< "Error while writing image (GDAL format) '"
<< m_FileName.c_str() << "' : " << CPLGetLastErrorMsg());
}
// Flush dataset cache
m_Dataset->GetDataSet()->FlushCache();
......@@ -1364,7 +1367,8 @@ void GDALImageIO::Write(const void* buffer)
NULL, NULL );
if(!hOutputDS)
{
itkExceptionMacro(<< "Error while writing image (GDAL format) " << m_FileName.c_str() << ".");
itkExceptionMacro(<< "Error while writing image (GDAL format) '"
<< m_FileName.c_str() << "' : " << CPLGetLastErrorMsg());
}
else
{
......@@ -1586,7 +1590,8 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer)
if (m_Dataset.IsNull())
{
itkExceptionMacro(
<< "GDAL Writing failed : Impossible to create the image file name '" << m_FileName << "'.");
<< "GDAL Writing failed : Impossible to create the image file name '"
<< m_FileName << "' : " << CPLGetLastErrorMsg() );
}
/*----------------------------------------------------------------------*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment