mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-05 22:04:27 +08:00
Implement the two deprecations that were planned for the 2020.09 release cycle (#3047)
* Deprecation: planned removal of .message() and .getMessage() methods * Deprecation: planned removal of old MolHash code * document deprecations * output the diffs when the psql tests fail * remove .message() from SWIG wrappers note that the KeyError doesn't work properly. We should clean up the the exceptions here anyway * typo
This commit is contained in:
@@ -19,7 +19,6 @@ class GenericRDKitException : public std::exception {
|
||||
GenericRDKitException(const std::string &i) : _value(i){};
|
||||
GenericRDKitException(const char *msg) : _value(msg){};
|
||||
const char *what() const noexcept override { return _value.c_str(); };
|
||||
const char *message() const noexcept { return what(); };
|
||||
~GenericRDKitException() noexcept {};
|
||||
|
||||
private:
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
%typemap(throws, throws="org.RDKit.ChemicalReactionException") RDKit::ChemicalReactionException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/ChemicalReactionException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
%typemap(throws, throws="org.RDKit.ChemicalReactionParserException") RDKit::ChemicalReactionParserException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/ChemicalReactionParserException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
%typemap(throws, throws="org.RDKit.ConformerException") RDKit::ConformerException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/ConformerException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
%typemap(throws, throws="org.RDKit.MolPicklerException") RDKit::MolPicklerException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/MolPicklerException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
%typemap(throws, throws="org.RDKit.MolSanitizeException") RDKit::MolSanitizeException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/MolSanitizeException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
%typemap(throws, throws="org.RDKit.SmilesParseException") RDKit::SmilesParseException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/SmilesParseException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -97,21 +97,16 @@
|
||||
%typemap(throws, throws="org.RDKit.KeyErrorException") KeyErrorException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/KeyErrorException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.key());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
%extend KeyErrorException {
|
||||
std::string message() {
|
||||
return "Unknown key: " + ($self)->key();
|
||||
}
|
||||
}
|
||||
|
||||
// ===== GenericRDKitException =====
|
||||
%typemap(javabase) RDKit::GenericRDKitException "java.lang.RuntimeException";
|
||||
%typemap(throws, throws="org.RDKit.GenericRDKitException") RDKit::GenericRDKitException {
|
||||
jclass excep = jenv->FindClass("org/RDKit/GenericRDKitException");
|
||||
if (excep)
|
||||
jenv->ThrowNew(excep, $1.message());
|
||||
jenv->ThrowNew(excep, $1.what());
|
||||
return $null;
|
||||
}
|
||||
|
||||
@@ -124,27 +119,27 @@
|
||||
$action
|
||||
} catch (RDKit::ChemicalReactionException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/ChemicalReactionException");
|
||||
jenv->ThrowNew(clazz, e.message());
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
} catch (RDKit::ChemicalReactionParserException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/ChemicalReactionParserException");
|
||||
jenv->ThrowNew(clazz, e.message());
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
} catch (RDKit::ConformerException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/ConformerException");
|
||||
jenv->ThrowNew(clazz, e.message());
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
} catch (RDKit::MolPicklerException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/MolPicklerException");
|
||||
jenv->ThrowNew(clazz, e.message());
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
} catch (RDKit::MolSanitizeException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/MolSanitizeException");
|
||||
jenv->ThrowNew(clazz, e.message());
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
} catch (RDKit::SmilesParseException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/SmilesParseException");
|
||||
jenv->ThrowNew(clazz, e.message());
|
||||
jenv->ThrowNew(clazz, e.what());
|
||||
return $null;
|
||||
} catch (KeyErrorException &e) {
|
||||
jclass clazz = jenv->FindClass("org/RDKit/KeyErrorException");
|
||||
|
||||
@@ -93,32 +93,32 @@
|
||||
}
|
||||
catch (RDKit::ChemicalReactionException &e) {
|
||||
std::string err="ChemicalReactionException: ";
|
||||
err+=e.message();
|
||||
err+=e.what();
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, err.c_str());
|
||||
}
|
||||
catch (RDKit::ChemicalReactionParserException &e) {
|
||||
std::string err="ChemicalReactionParserException: ";
|
||||
err+=e.message();
|
||||
err+=e.what();
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, err.c_str());
|
||||
}
|
||||
catch (RDKit::ConformerException &e) {
|
||||
std::string err="ConformerException: ";
|
||||
err+=e.message();
|
||||
err+=e.what();
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, err.c_str());
|
||||
}
|
||||
catch (RDKit::MolPicklerException &e) {
|
||||
std::string err="MolPicklerException: ";
|
||||
err+=e.message();
|
||||
err+=e.what();
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, err.c_str());
|
||||
}
|
||||
catch (RDKit::MolSanitizeException &e) {
|
||||
std::string err="MolSanitizeException: ";
|
||||
err+=e.message();
|
||||
err+=e.what();
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, err.c_str());
|
||||
}
|
||||
catch (RDKit::SmilesParseException e) {
|
||||
std::string err="SmilesParseException: ";
|
||||
err+=e.message();
|
||||
err+=e.what();
|
||||
SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, err.c_str());
|
||||
}
|
||||
catch (KeyErrorException e) {
|
||||
|
||||
@@ -58,8 +58,8 @@ public class ErrorHandlingTests extends GraphMolTest {
|
||||
e.getClass().toString());
|
||||
String what = ((KeyErrorException) e).key();
|
||||
assertEquals("monkey", what);
|
||||
what = ((KeyErrorException) e).message();
|
||||
assertEquals("Unknown key: monkey", what);
|
||||
// what = ((KeyErrorException) e).what();
|
||||
// assertEquals("Unknown key: monkey", what);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ErrorHandlingTests extends GraphMolTest {
|
||||
}
|
||||
catch (GenericRDKitException e)
|
||||
{
|
||||
String what = e.message();
|
||||
String what = e.what();
|
||||
assertEquals("Unknown exception", what);
|
||||
String where = e.getStackTrace()[0].getMethodName();
|
||||
assertEquals("ROMol_getAtomWithIdx", where);
|
||||
@@ -111,7 +111,7 @@ public class ErrorHandlingTests extends GraphMolTest {
|
||||
{
|
||||
assertEquals("class org.RDKit.GenericRDKitException",
|
||||
e.getClass().toString());
|
||||
String msg = e.message();
|
||||
String msg = e.what();
|
||||
assertEquals("Unknown exception", msg);
|
||||
StackTraceElement[] st = e.getStackTrace();
|
||||
assertEquals("ErrorGenerator_badAlloc_1",
|
||||
|
||||
Reference in New Issue
Block a user