>
> If you download the latest source, with the Java API, or the hdf-java
3.2.1 source - you can inspect the JNI code for exceptions in the native
hdf5 exceptionImp.c file.
> Another source of using the exception API for custom error reporting is
the tools library and h5dump.
Ah, thanks for the pointers Allen. I actually think I came across the JNI
code during my googlings, but didn't look closer at it before I got busy
with other things. I'll take a look when I'm back at it.
I looked at it briefly again, and the JNI code looks like it's doing
exactly what I want (a custom walker + H5E_walk2 to just get the top error,
and then H5E_get_msg to get the corresponding message). Many thanks.
I think when I was trying to figure it out on my own, I didn't realize it's
the minor error code I should feed to H5E_get_msg.
Elvis
Elvis
>
> Allen
>
> > Hi Rob,
> >
> >
> > >
> > >
> > >
> > >> Hi all,
> > >>
> > >> Is it possible to get some more informative error from H5Fopen than
> > >> "it failed"? E.g. if it was a permission problem, nonexistent file,
> > >> corrupted file, ...? Or must I try to deduce the reason for the
> > >> failure myself? (always risky to do such checks pre- or
post-mortem so
> > >> to speak..).
> > >>
> > >
> > > I think you are going to have to share your output with the list.
Whenever
> > > *I* run hdf5 and get an error I get screenfuls of information.
> > >
> > > For example, here's a simple hdf5 program trying to open a file for
which
> > > I have removed all read and write permissions:
> > >
> >
> > Yes, and I'm sorry. I should have replied to myself quite soon after
I sent
> > my message, but somehow forgot about it.
> >
> > When I first wrote my message, I was
> >
> > 1. working through the C++ API, and
> > 2. building my program in release mode.
> >
> > Working through the C++ API meant I was using
> > H5::Exception::getDetailMsg(), hoping to get some detailed message,
but it
> > was giving me something like "H5Fopen failed" (which is why I
mentioned the
> > H5Fopen C function in my post). Building my program in release mode
also
> > meant I did not get the detailed error stack printout that the C
layer does
> > by default in debug mode (like you showed below). That's why I was a
little
> > puzzled.
> >
> > Since I wrote my message, I have
> >
> > 1. switched to working with the C API (through a simple HDF5File C++
> > class of my own),
> > 2. learned all about the gory details of the H5E API [1] and error
> > handling in chapter 9 of the User Guide.
> >
> > So I'm all good now Though I must say the error handling API is
quite
> > complicated (I still haven't written my custom error
walking/formatting
> > functions, so only relying on the default printouts I get in debug
mode).
> >
> > One thing that I would wish for is
> >
> > 1. an API similar to H5Eprint that would take an output char*
parameter
> > instead of a FILE*,
> > 2. a simpler API to just get the human readable message (if any)
for the
> > most likely "root cause" for the latest error.
> >
> > 1 because if you're interested in getting the error trace into a
string
> > (for e.g. showing it in the UI), then setting up an in-memory FILE*
is not
> > something that can be easily done in a portable way (I know about
> > fmemopen/open_memstream, but they are POSIX). I know this can be done
by
> > setting up your own error stack walking function, but it's quite
awkward to
> > have to do that, especially if you're happy with the formatting that
HDF5
> > does by default, and you just want the result as a string instead.
> >
> > 2 because like others have mentioned, sometimes you're not interested
in
> > the full trace, but only the likely root cause (which is probably
somewhere
> > at the bottom of the stack).
> >
> > Anyway, thanks for chiming in, and sorry again for not following up
on my
> > own post earlier.
> >
> > Elvis
> >
> >
> > >
> > > HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:
> > > #000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen():
unable to
> > > open file
> > > major: File accessibilty
> > > minor: Unable to open file
> > > #001: ../../../hdf5-1.8.16/src/H5Fint.c line 992 in H5F_open():
unable
> > > to open file: time = Mon Nov 28 14:41:40 2016
> > > , name = 'try.h5', tent_flags = 1
> > > major: File accessibilty
> > > minor: Unable to open file
> > > #002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD_open():
open
> > > failed
> > > major: Virtual File Layer
> > > minor: Unable to initialize object
> > > #003: ../../../hdf5-1.8.16/src/H5FDsec2.c line 339 in
H5FD_sec2_open():
> > > unable to open file: name = 'try.h5', errno = 13, error message =
> > > 'Permission denied', flags = 1, o_flags = 2
> > > major: File accessibilty
> > > minor: Unable to open file
> > >
> > >
> > >> Thanks in advance,
> > >> Elvis
> > >>
> > >> _______________________________________________
> > >> Hdf-forum is for HDF software users discussion.
> > >> Hdf-forum@lists.hdfgroup.org
> > >>
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
> > >> Twitter: https://twitter.com/hdf5
> > >>
> > >>
> > > _______________________________________________
> > > Hdf-forum is for HDF software users discussion.
> > > Hdf-forum@lists.hdfgroup.org
> > >
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
···
Den 29 nov. 2016 5:41 em skrev "Elvis Stansvik" < elvis.stansvik@orexplore.com>:
Den 29 nov. 2016 3:32 em skrev "Allen Byrne" <byrn@hdfgroup.org>:
> On Tuesday, November 29, 2016 9:20:03 AM CST Elvis Stansvik wrote:
> > 2016-11-28 21:43 GMT+01:00 Rob Latham <robl@mcs.anl.gov>:
> > > On 11/08/2016 01:18 PM, Elvis Stansvik wrote:
> > > Twitter: https://twitter.com/hdf5
> > >
> >
>
>