Capture C++ Exception

I have been trying to capture an error that has bee showing up in my syslog (Not that this is a python script that calls a C++ Class):

Sep 3 13:42:27 awdn1 python3[9414]: HDF5-DIAG: Error detected in HDF5 (1.10.0-patch1) thread 139689250795008:
Sep 3 13:42:27 awdn1 python3[9414]: #000: …/…/…/src/H5F.c line 579 in H5Fopen(): unable to open file
Sep 3 13:42:27 awdn1 python3[9414]: major: File accessibilty
Sep 3 13:42:27 awdn1 python3[9414]: minor: Unable to open file
Sep 3 13:42:27 awdn1 python3[9414]: #001: …/…/…/src/H5Fint.c line 1168 in H5F_open(): unable to lock the file or initialize file structure
Sep 3 13:42:27 awdn1 python3[9414]: major: File accessibilty
Sep 3 13:42:27 awdn1 python3[9414]: minor: Unable to open file
Sep 3 13:42:27 awdn1 python3[9414]: #002: …/…/…/src/H5FD.c line 1821 in H5FD_lock(): driver lock request failed
Sep 3 13:42:27 awdn1 python3[9414]: major: Virtual File Layer
Sep 3 13:42:27 awdn1 python3[9414]: minor: Can’t update object
Sep 3 13:42:27 awdn1 python3[9414]: #003: …/…/…/src/H5FDsec2.c line 939 in H5FD_sec2_lock(): unable to flock file, errno = 11, error message = ‘Resource temporarily unavailable’
Sep 3 13:42:27 awdn1 python3[9414]: major: File accessibilty
Sep 3 13:42:27 awdn1 python3[9414]: minor: Bad file ID accessed

So far for my program I have tried:

catch(H5::FileIException &err) { std::cout << err.getDetailMsg() << std::endl;}
catch(H5::DataSetIException &err) {std::cout << err.getDetailMsg() << std::endl;}
catch(H5::DataSpaceIException &err) {std::cout << err.getDetailMsg() << std::endl;}

That did not output the above HDF5-DIAG error. What code do I need to get the catch to grab and print this error?

Hello,

H5::FileIException should do it, but how about H5::Exception? Also, please
try print just some text to make sure, in case getDetailMsg() didn’t do what
we expect.

Thanks,

So yah, I did do some prints to make sure what error was being returned. What was given was:

FileIException
H5Fopen failed

I’ll look into H5::Exception and see if it will capture anything else. I’m also going to add printError() and see that that gives me.

Ah, I see what you wanted to print. Sorry for not getting it!

By any chance, did you have this statement somewhere at the beginning
of your code?
Exception::dontPrint();

Since it did print H5Fopen failed, don’t worry about trying H5::Exception.

I do not have to exception in the code

I’m not sure what you meant by that, but “Exception::dontPrint()” will turn off the automatic error printing, so I thought, perhaps, your code or some code it is linked to might call that.

Sorry didnt mean to seem glib. I searched all my code and did not find any calls to dontPrint(). Would dontPrint() keep Exception from printing to syslog as well?

Let me find out some more and get back to you.

Binh-Minh

I haven’t been able to capture any other errors other than “H5Fopen failed”. If the error above in the OP is not part of printError() or getDetailMsg() in the H5::Exception class then what is it from?

I’m sorry, it’s been a while… The error messages came from the C library.