send better error message in c++, pass along in py

LT1AB
scott 2021-07-07 08:19:30 -05:00
parent 48b513fc42
commit 99d478f87e
2 changed files with 14 additions and 15 deletions

View File

@ -143,8 +143,7 @@ createAccessor_C(PyObject* self, PyObject* args)
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
PyErr_SetString(PyExc_OSError, "Failed to created DataAccessor.");
PyErr_SetString(PyExc_OSError, e.what());
return NULL;
}

View File

@ -72,19 +72,19 @@ GDALAccessor::openFile (string filename, string accessMode, GDALDataset ** fd)
(*fd) = (GDALDataset *) GDALOpenShared (filename.c_str (), GA_ReadOnly);
if ((*fd) == NULL)
{
cout << "Error. Cannot open the file " << filename << " in "
<< accessMode << " mode." << endl;
throw runtime_error("GDAL file open error.");
string errMsg = "Cannot open the file " + filename + " in "
+ accessMode + " mode.";
throw runtime_error(errMsg);
// ERR_MESSAGE
;
// ;
}
}
else
{
cout << "Error. Only read mode is available and not " << accessMode
<< " mode." << endl;
ERR_MESSAGE
;
string errMsg = "Error. Only read mode is available and not " + accessMode + " mode.";
throw runtime_error(errMsg);
// ERR_MESSAGE
// ;
}
}