throw exception from c++ GdalAccessor instead of exit(1)
Leads to an OSError being thrown instead of shutting down the whole programLT1AB
parent
3928c3bdb7
commit
48b513fc42
|
@ -135,9 +135,19 @@ createAccessor_C(PyObject* self, PyObject* args)
|
|||
exit(1);
|
||||
}
|
||||
if (casterCh[0] == '\0')
|
||||
{
|
||||
try
|
||||
{
|
||||
ptDataAccessor = (uint64_t) AF->createAccessor(filename, filemode, size,
|
||||
bands, width, scheme);
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
PyErr_SetString(PyExc_OSError, "Failed to created DataAccessor.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else if (casterCh[0] != '\0' && PyDict_Size(dict) == 0)
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
#include "InterleavedBase.h"
|
||||
#include <stdint.h>
|
||||
#include "gdal_priv.h"
|
||||
|
|
|
@ -71,10 +71,11 @@ GDALAccessor::openFile (string filename, string accessMode, GDALDataset ** fd)
|
|||
std::cout << "GDAL open (R): " << filename << std::endl;
|
||||
(*fd) = (GDALDataset *) GDALOpenShared (filename.c_str (), GA_ReadOnly);
|
||||
if ((*fd) == NULL)
|
||||
{
|
||||
{
|
||||
cout << "Error. Cannot open the file " << filename << " in "
|
||||
<< accessMode << " mode." << endl;
|
||||
ERR_MESSAGE
|
||||
throw runtime_error("GDAL file open error.");
|
||||
// ERR_MESSAGE
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue