Sire icon indicating copy to clipboard operation
Sire copied to clipboard

No way to expose full C++ backtrace to Python

Open lohedges opened this issue 3 years ago • 2 comments

Currently the full C++ backtrace is not exposed to the Python wrappers so cannot be parsed, e.g. by BioSimSpace. This is used in various places to provide additional contextual information to the user. Currently the output implies that the functionality can be exposed by calling sire.error.enable_backtrace_exceptions(), but this function doesn't appear to be exposed (yet).

For example:

{'why': 'There are no lead parsers!',
 'backtrace': 'Backtrace disabled. Call sire.error.enable_backtrace_exceptions() to re-enable.',
 'pid': '',
 'type': 'SireError::program_bug',
 'where': 'FILE: /home/lester/Code/Sire/corelib/src/libs/SireIO/moleculeparser.cpp, LINE: 1838, FUNCTION: void SireIO::MoleculeParser::sortParsers(QList<SireBase::PropPtr<SireIO::MoleculeParser> >&, QList<SireBase::PropPtr<SireIO::MoleculeParser> >&) const',
 'from': 'FILE: /home/lester/Code/Sire/corelib/src/libs/SireIO/moleculeparser.cpp, LINE: 1838, FUNCTION: void SireIO::MoleculeParser::sortParsers(QList<SireBase::PropPtr<SireIO::MoleculeParser> >&, QList<SireBase::PropPtr<SireIO::MoleculeParser> >&) const'}

In this case, we only get the last error message. I would like to be able to parse the full trace to see if this was due to the presence of CMAP records, which are currently unsupported, e.g. in relation to this issue.

(The only function that currently appears to be exposed through sire.error is get_last_error_details.)

lohedges avatar Oct 03 '22 09:10 lohedges

Okay, I figured out that this functionality resides in the sire.legacy.Error package, not sire.error as described by the error message above. I'll leave this open for now, although I imagine that it will be resolved as the full 2023 API is fleshed out.

lohedges avatar Oct 03 '22 10:10 lohedges

Thanks - yes, I forgot to expose this in sire.error. Yes, this will need fleshing out and fixing before the 2023.1 release.

I made the change to disable backtraces by default as they were a major performance hit in key parts of the code. Ideally I'd like to find a way to automatically enable them when needed... but am not sure this is possible?

chryswoods avatar Oct 25 '22 16:10 chryswoods