Put the call in a try block and print the error message. Something like this:
try:
cppPrevTx = TheBDM.bdv().getTxByHash(txhash)
except DbErrorMsg as e:
print e.what()
raise e
Btw this traceback is for code from master (0.96.3). Have you reproduced the same issue with the testing branch?