# More informative error from H5Fopen?

**URL:** <https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912>\
**Category:** Hdf-forum archives\
**Created:** [November 8, 2016, 7:18pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912 "2016-11-08T19:18:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![elvis.stansvik](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@elvis.stansvik](https://forum.hdfgroup.org/u/elvis.stansvik)\
**Post date:** [November 8, 2016, 7:18pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/1 "2016-11-08T19:18:44Z")

</div>

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..).

Thanks in advance,  
Elvis

---

<div class="post-metadata">

**Author:** ![robl](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@robl](https://forum.hdfgroup.org/u/robl)\
**Post date:** [November 28, 2016, 8:43pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/2 "2016-11-28T20:43:58Z")

</div>

> 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:

HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
&nbsp;&nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen(): unable to open file  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
&nbsp;&nbsp;&nbsp;#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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
&nbsp;&nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD\_open(): open failed  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
&nbsp;&nbsp;&nbsp;#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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file

> **···**
>
> On 11/08/2016 01:18 PM, Elvis Stansvik wrote:
> 
> > 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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > Twitter: [x.com](https://twitter.com/hdf5)

---

<div class="post-metadata">

**Author:** ![miller86](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/miller86/32/124_2.png) [@miller86](https://forum.hdfgroup.org/u/miller86)\
**Post date:** [November 28, 2016, 9:32pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/3 "2016-11-28T21:32:31Z")

</div>

"Hdf-forum on behalf of Rob Latham" wrote:

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:

HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
&nbsp;&nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen(): unable to  
open file  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
&nbsp;&nbsp;&nbsp;#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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
&nbsp;&nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD\_open(): open  
failed  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
&nbsp;&nbsp;&nbsp;#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  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file

I am not sure how other users feel about this and it may not even be the original poster's ( Elvis Stansvik) complaint but a big challenge I have with interpreting HDF5 errors \*is\* the "...screenfuls of information".

It is challenging to paw through it to discover the root cause.

For example, in the above error stack, we get information about why sec2 VFD failed..."errno=13 ("Permission enied") but what are 'flags' and 'o\_flags' there? Are these params to sec2 open call? That has only an 'oflag' argument and not an additional 'flags' argument. And, their numeric values, '1' and '2' are too informatvie either. What about similar info at the HDF5 public interface (e.g. H5Fopen)? What was passed for 'flags' there. Oh, maybe 'flags' in the #003 trace \*is\* the 'flags' argument caller passed to H5Fopen and 'o\_flags' is what HDF5 lib passed to sec2 open call? I could see having 'flags' emitted in the #000 trace if that is indeed the argument passed as 'flags' to H5Fopen. and 'oflags' not 'o\_flags' emitted in the #003 trace. Finally, it would be \*much\* more helpful to see the symbolic constants for the flags and not their numerics.

So, I personally find grocking HDF5 error stack output very awkward.

It may be that it is awkward enough for others that no one really is able to find the information they needed in it (e.g. the signal to noise ratio is just way too low).

My two cents.

Mark

> **···**
>
> --  
> Mark C. Miller, LLNL
> 
> "In the end, we will remember not the words of  
> our enemies but the silence of our friends" - MLK

---

<div class="post-metadata">

**Author:** ![elvis.stansvik](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@elvis.stansvik](https://forum.hdfgroup.org/u/elvis.stansvik)\
**Post date:** [November 29, 2016, 8:20am UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/4 "2016-11-29T08:20:03Z")

</div>

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

&nbsp;&nbsp;1. working through the C++ API, and  
&nbsp;&nbsp;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

&nbsp;&nbsp;1. switched to working with the C API (through a simple HDF5File C++  
class of my own),  
&nbsp;&nbsp;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

&nbsp;&nbsp;1. an API similar to H5Eprint that would take an output char\* parameter  
instead of a FILE\*,  
&nbsp;&nbsp;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

> **···**
>
> 2016-11-28 21:43 GMT+01:00 Rob Latham \<robl@mcs.anl.gov\>:
> 
> > On 11/08/2016 01:18 PM, Elvis Stansvik wrote:
> 
> > HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
> > &nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen(): unable to  
> > open file  
> > &nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > &nbsp;&nbsp;#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  
> > &nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > &nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD\_open(): open  
> > failed  
> > &nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
> > &nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
> > &nbsp;&nbsp;#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  
> > &nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > > Twitter: [x.com](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > Twitter: [x.com](https://twitter.com/hdf5)

---

<div class="post-metadata">

**Author:** ![Landon\_Clipp](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Landon\_Clipp](https://forum.hdfgroup.org/u/Landon_Clipp)\
**Post date:** [November 28, 2016, 10:26pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/5 "2016-11-28T22:26:17Z")

</div>

Mark,

I get what you mean. I have rarely found the error output of HDF5 to be of  
much use, although sometimes it can be helpful. For instance just off the  
top of my head, I've been getting errors about HDF attributes. I've called  
H5Aclose and I get errors about the argument not being an attribute. Turns  
out the variable I passed was never initialized. So in that case it's  
helpful.

One thing to realize is that the error is most likely NOT reading in the  
library itself. I recommend that you use a debugger like GDB to find  
exactly what you are passing into the function and to see if every value  
you're passing in makes sense. That's really the only way to go about it.

It all comes down to this: H5Fopen is failing and there are a finite number  
of issues we can address.

1. Does the file exist, and if so are you providing the correct path to it  
(relative or absolute)? Do you have read/write permission for the file?  
2. Have you misspelled the file?  
3. Are you providing either DF\_ACC\_RDWR or DF\_ACC\_RDONLY to the second  
argument? Only those two arguments are valid.  
4. What file access property list are you providing? You should be able to  
rule out providing a buggy access property by just passing in the default  
parameter.

I guarantee that your error lies in one of these issues. I recommend you  
make the second and third arguments the read only and default respectively.  
That will isolate the problem to your first argument and whether or not you  
have appropriate file permissions.

Regards,  
Landon

> **···**
>
> On Nov 28, 2016 3:33 PM, "Miller, Mark C." \<miller86@llnl.gov\> wrote:
> 
> > "Hdf-forum on behalf of Rob Latham" wrote:
> > 
> > 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:
> > 
> > HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
> > &nbsp;&nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen(): unable to  
> > open file  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > &nbsp;&nbsp;&nbsp;#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  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > &nbsp;&nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD\_open(): open  
> > failed  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
> > &nbsp;&nbsp;&nbsp;#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  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file
> > 
> > I am not sure how other users feel about this and it may not even be the  
> > original poster's ( Elvis Stansvik) complaint but a big challenge I have  
> > with interpreting HDF5 errors \*is\* the "...screenfuls of information".
> > 
> > It is challenging to paw through it to discover the root cause.
> > 
> > For example, in the above error stack, we get information about why sec2  
> > VFD failed..."errno=13 ("Permission enied") but what are 'flags' and  
> > 'o\_flags' there? Are these params to sec2 open call? That has only an  
> > 'oflag' argument and not an additional 'flags' argument. And, their numeric  
> > values, '1' and '2' are too informatvie either. What about similar info at  
> > the HDF5 public interface (e.g. H5Fopen)? What was passed for 'flags'  
> > there. Oh, maybe 'flags' in the #003 trace \*is\* the 'flags' argument caller  
> > passed to H5Fopen and 'o\_flags' is what HDF5 lib passed to sec2 open call?  
> > I could see having 'flags' emitted in the #000 trace if that is indeed the  
> > argument passed as 'flags' to H5Fopen. and 'oflags' not 'o\_flags' emitted  
> > in the #003 trace. Finally, it would be \*much\* more helpful to see the  
> > symbolic constants for the flags and not their numerics.
> > 
> > So, I personally find grocking HDF5 error stack output very awkward.
> > 
> > It may be that it is awkward enough for others that no one really is able  
> > to find the information they needed in it (e.g. the signal to noise ratio  
> > is just way too low).
> > 
> > My two cents.
> > 
> > Mark
> > 
> > --  
> > Mark C. Miller, LLNL
> > 
> > "In the end, we will remember not the words of  
> > our enemies but the silence of our friends" - MLK
> > 
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > Hdf-forum is for HDF software users discussion.  
> > Hdf-forum@lists.hdfgroup.org  
> > [http://lists.hdfgroup.org/mailman/listinfo/hdf-forum\_lists.hdfgroup.org](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > Twitter: [x.com](https://twitter.com/hdf5)

---

<div class="post-metadata">

**Author:** ![Landon\_Clipp](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/l/ecae2f/32.png) [@Landon\_Clipp](https://forum.hdfgroup.org/u/Landon_Clipp)\
**Post date:** [November 28, 2016, 10:28pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/6 "2016-11-28T22:28:48Z")

</div>

Also one more possible issue I'd add onto my list there: it is possible  
that the file is corrupt. So try ruling that out by making an empty HDF5  
file in the same directory as the one you're trying to access and run the  
same functions, only opening this new file instead.

Regards,  
Landon

> **···**
>
> On Nov 28, 2016 4:26 PM, "Landon Clipp" \<clipp2@illinois.edu\> wrote:
> 
> > Mark,
> > 
> > I get what you mean. I have rarely found the error output of HDF5 to be of  
> > much use, although sometimes it can be helpful. For instance just off the  
> > top of my head, I've been getting errors about HDF attributes. I've called  
> > H5Aclose and I get errors about the argument not being an attribute. Turns  
> > out the variable I passed was never initialized. So in that case it's  
> > helpful.
> > 
> > One thing to realize is that the error is most likely NOT reading in the  
> > library itself. I recommend that you use a debugger like GDB to find  
> > exactly what you are passing into the function and to see if every value  
> > you're passing in makes sense. That's really the only way to go about it.
> > 
> > It all comes down to this: H5Fopen is failing and there are a finite  
> > number of issues we can address.
> > 
> > 1. Does the file exist, and if so are you providing the correct path to it  
> > (relative or absolute)? Do you have read/write permission for the file?  
> > 2. Have you misspelled the file?  
> > 3. Are you providing either DF\_ACC\_RDWR or DF\_ACC\_RDONLY to the second  
> > argument? Only those two arguments are valid.  
> > 4. What file access property list are you providing? You should be able to  
> > rule out providing a buggy access property by just passing in the default  
> > parameter.
> > 
> > I guarantee that your error lies in one of these issues. I recommend you  
> > make the second and third arguments the read only and default respectively.  
> > That will isolate the problem to your first argument and whether or not you  
> > have appropriate file permissions.
> > 
> > Regards,  
> > Landon
> > 
> > On Nov 28, 2016 3:33 PM, "Miller, Mark C." \<miller86@llnl.gov\> wrote:
> > 
> > > "Hdf-forum on behalf of Rob Latham" wrote:
> > > 
> > > 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:
> > > 
> > > HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
> > > &nbsp;&nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen(): unable to  
> > > open file  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > > &nbsp;&nbsp;&nbsp;#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  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > > &nbsp;&nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD\_open(): open  
> > > failed  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
> > > &nbsp;&nbsp;&nbsp;#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  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file
> > > 
> > > I am not sure how other users feel about this and it may not even be the  
> > > original poster's ( Elvis Stansvik) complaint but a big challenge I have  
> > > with interpreting HDF5 errors \*is\* the "...screenfuls of information".
> > > 
> > > It is challenging to paw through it to discover the root cause.
> > > 
> > > For example, in the above error stack, we get information about why sec2  
> > > VFD failed..."errno=13 ("Permission enied") but what are 'flags' and  
> > > 'o\_flags' there? Are these params to sec2 open call? That has only an  
> > > 'oflag' argument and not an additional 'flags' argument. And, their numeric  
> > > values, '1' and '2' are too informatvie either. What about similar info at  
> > > the HDF5 public interface (e.g. H5Fopen)? What was passed for 'flags'  
> > > there. Oh, maybe 'flags' in the #003 trace \*is\* the 'flags' argument caller  
> > > passed to H5Fopen and 'o\_flags' is what HDF5 lib passed to sec2 open call?  
> > > I could see having 'flags' emitted in the #000 trace if that is indeed the  
> > > argument passed as 'flags' to H5Fopen. and 'oflags' not 'o\_flags' emitted  
> > > in the #003 trace. Finally, it would be \*much\* more helpful to see the  
> > > symbolic constants for the flags and not their numerics.
> > > 
> > > So, I personally find grocking HDF5 error stack output very awkward.
> > > 
> > > It may be that it is awkward enough for others that no one really is able  
> > > to find the information they needed in it (e.g. the signal to noise ratio  
> > > is just way too low).
> > > 
> > > My two cents.
> > > 
> > > Mark
> > > 
> > > --  
> > > Mark C. Miller, LLNL
> > > 
> > > "In the end, we will remember not the words of  
> > > our enemies but the silence of our friends" - MLK
> > > 
> > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > Hdf-forum is for HDF software users discussion.  
> > > Hdf-forum@lists.hdfgroup.org  
> > > [http://lists.hdfgroup.org/mailman/listinfo/hdf-forum\_lists.hdfgroup.org](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > > Twitter: [x.com](https://twitter.com/hdf5)

---

<div class="post-metadata">

**Author:** ![robl](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@robl](https://forum.hdfgroup.org/u/robl)\
**Post date:** [November 29, 2016, 3:25am UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/7 "2016-11-29T03:25:45Z")

</div>

> Also one more possible issue I'd add onto my list there: it is possible  
> that the file is corrupt. So try ruling that out by making an empty HDF5  
> file in the same directory as the one you're trying to access and run  
> the same functions, only opening this new file instead.

I think Mark and Landon are saying the same things here, but in different ways.

The 300-some HDF5 user-facing interfaces should return something helpful. The internal interfaces between, say, H5Fopen and lowest-level posix open(2) system call are not helpful for users. The probably aren't all that helpful for developers at this point in the HDF5 life cycle, either.

==rob

> **···**
>
> On 11/28/2016 04:28 PM, Landon Clipp wrote:
> 
> > Regards,  
> > Landon
> > 
> > On Nov 28, 2016 4:26 PM, "Landon Clipp" \<clipp2@illinois.edu \> \<mailto:clipp2@illinois.edu\>\> wrote:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;Mark,
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;I get what you mean. I have rarely found the error output of HDF5 to  
> > &nbsp;&nbsp;&nbsp;&nbsp;be of much use, although sometimes it can be helpful. For instance  
> > &nbsp;&nbsp;&nbsp;&nbsp;just off the top of my head, I've been getting errors about HDF  
> > &nbsp;&nbsp;&nbsp;&nbsp;attributes. I've called H5Aclose and I get errors about the argument  
> > &nbsp;&nbsp;&nbsp;&nbsp;not being an attribute. Turns out the variable I passed was never  
> > &nbsp;&nbsp;&nbsp;&nbsp;initialized. So in that case it's helpful.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;One thing to realize is that the error is most likely NOT reading in  
> > &nbsp;&nbsp;&nbsp;&nbsp;the library itself. I recommend that you use a debugger like GDB to  
> > &nbsp;&nbsp;&nbsp;&nbsp;find exactly what you are passing into the function and to see if  
> > &nbsp;&nbsp;&nbsp;&nbsp;every value you're passing in makes sense. That's really the only  
> > &nbsp;&nbsp;&nbsp;&nbsp;way to go about it.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;It all comes down to this: H5Fopen is failing and there are a finite  
> > &nbsp;&nbsp;&nbsp;&nbsp;number of issues we can address.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;1. Does the file exist, and if so are you providing the correct path  
> > &nbsp;&nbsp;&nbsp;&nbsp;to it (relative or absolute)? Do you have read/write permission for  
> > &nbsp;&nbsp;&nbsp;&nbsp;the file?  
> > &nbsp;&nbsp;&nbsp;&nbsp;2. Have you misspelled the file?  
> > &nbsp;&nbsp;&nbsp;&nbsp;3. Are you providing either DF\_ACC\_RDWR or DF\_ACC\_RDONLY to the  
> > &nbsp;&nbsp;&nbsp;&nbsp;second argument? Only those two arguments are valid.  
> > &nbsp;&nbsp;&nbsp;&nbsp;4. What file access property list are you providing? You should be  
> > &nbsp;&nbsp;&nbsp;&nbsp;able to rule out providing a buggy access property by just passing  
> > &nbsp;&nbsp;&nbsp;&nbsp;in the default parameter.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;I guarantee that your error lies in one of these issues. I recommend  
> > &nbsp;&nbsp;&nbsp;&nbsp;you make the second and third arguments the read only and default  
> > &nbsp;&nbsp;&nbsp;&nbsp;respectively. That will isolate the problem to your first argument  
> > &nbsp;&nbsp;&nbsp;&nbsp;and whether or not you have appropriate file permissions.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;Regards,  
> > &nbsp;&nbsp;&nbsp;&nbsp;Landon
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;On Nov 28, 2016 3:33 PM, "Miller, Mark C." \<miller86@llnl.gov \> \<mailto:miller86@llnl.gov\>\> wrote:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Hdf-forum on behalf of Rob Latham" wrote:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I think you are going to have to share your output with the  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list.  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Whenever \*I\* run hdf5 and get an error I get screenfuls of  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;information.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For example, here's a simple hdf5 program trying to open a  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file for  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;which I have removed all read and write permissions:
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5Fopen(): unable to  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;open file  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#001: ../../../hdf5-1.8.16/src/H5Fint.c line 992 in  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5F\_open():  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;unable to open file: time = Mon Nov 28 14:41:40 2016  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;, name = 'try.h5', tent\_flags = 1  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5FD\_open(): open  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;failed  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#003: ../../../hdf5-1.8.16/src/H5FDsec2.c line 339 in  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H5FD\_sec2\_open(): unable to open file: name = 'try.h5',  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errno = 13,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;error message = 'Permission denied', flags = 1, o\_flags = 2  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I am not sure how other users feel about this and it may not  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;even be the original poster's ( Elvis Stansvik) complaint but a  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;big challenge I have with interpreting HDF5 errors \*is\* the  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"...screenfuls of information".
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It is challenging to paw through it to discover the root cause.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For example, in the above error stack, we get information about  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;why sec2 VFD failed..."errno=13 ("Permission enied") but what  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;are 'flags' and 'o\_flags' there? Are these params to sec2 open  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call? That has only an 'oflag' argument and not an additional  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'flags' argument. And, their numeric values, '1' and '2' are too  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;informatvie either. What about similar info at the HDF5 public  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;interface (e.g. H5Fopen)? What was passed for 'flags' there. Oh,  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maybe 'flags' in the #003 trace \*is\* the 'flags' argument caller  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;passed to H5Fopen and 'o\_flags' is what HDF5 lib passed to sec2  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;open call? I could see having 'flags' emitted in the #000 trace  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if that is indeed the argument passed as 'flags' to H5Fopen. and  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'oflags' not 'o\_flags' emitted in the #003 trace. Finally, it  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;would be \*much\* more helpful to see the symbolic constants for  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the flags and not their numerics.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;So, I personally find grocking HDF5 error stack output very  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;awkward.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It may be that it is awkward enough for others that no one  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;really is able to find the information they needed in it (e.g.  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the signal to noise ratio is just way too low).
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;My two cents.
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mark
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Mark C. Miller, LLNL
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"In the end, we will remember not the words of  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;our enemies but the silence of our friends" - MLK
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hdf-forum is for HDF software users discussion.  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hdf-forum@lists.hdfgroup.org \<mailto:Hdf-forum@lists.hdfgroup.org\>  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[http://lists.hdfgroup.org/mailman/listinfo/hdf-forum\_lists.hdfgroup.org](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<[http://lists.hdfgroup.org/mailman/listinfo/hdf-forum\_lists.hdfgroup.org&gt](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org&gt);  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Twitter: [https://twitter.com/hdf5](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > Twitter: [https://twitter.com/hdf5](https://twitter.com/hdf5)

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [November 29, 2016, 2:32pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/8 "2016-11-29T14:32:52Z")

</div>

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.

Allen

> **···**
>
> On Tuesday, November 29, 2016 9:20:03 AM CST Elvis Stansvik wrote:
> 
> > Hi Rob,
> > 
> > 2016-11-28 21:43 GMT+01:00 Rob Latham \<robl@mcs.anl.gov\>:
> > 
> > \>  
> > \>  
> > \> On 11/08/2016 01:18 PM, Elvis Stansvik wrote:  
> > \>  
> > \>\> 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
> > 
> > &nbsp;&nbsp;1. working through the C++ API, and  
> > &nbsp;&nbsp;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
> > 
> > &nbsp;&nbsp;1. switched to working with the C API (through a simple HDF5File C++  
> > class of my own),  
> > &nbsp;&nbsp;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
> > 
> > &nbsp;&nbsp;1. an API similar to H5Eprint that would take an output char\* parameter  
> > instead of a FILE\*,  
> > &nbsp;&nbsp;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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > \>\> Twitter: [x.com](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > \> Twitter: [x.com](https://twitter.com/hdf5)  
> > \>

---

<div class="post-metadata">

**Author:** ![elvis.stansvik](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@elvis.stansvik](https://forum.hdfgroup.org/u/elvis.stansvik)\
**Post date:** [November 29, 2016, 8:24am UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/9 "2016-11-29T08:24:36Z")

</div>

> Also one more possible issue I'd add onto my list there: it is possible  
> that the file is corrupt. So try ruling that out by making an empty HDF5  
> file in the same directory as the one you're trying to access and run the  
> same functions, only opening this new file instead.

Ah yes, sorry I should have been more clear: In my case I wasn't debugging  
a particular failure, just looking for a way to get as much info out of  
HDF5 as possible to present together with an error message to the user  
(it's a GUI application) (see also my response to Rob just now).

Thanks for this suggestion and the ones below as well though. They will  
surely help when things truly hit the fan 🙂

Elvis

> **···**
>
> 2016-11-28 23:28 GMT+01:00 Landon Clipp \<clipp2@illinois.edu\>:
> 
> > Regards,  
> > Landon
> > 
> > On Nov 28, 2016 4:26 PM, "Landon Clipp" \<clipp2@illinois.edu\> wrote:
> > 
> > > Mark,
> > > 
> > > I get what you mean. I have rarely found the error output of HDF5 to be  
> > > of much use, although sometimes it can be helpful. For instance just off  
> > > the top of my head, I've been getting errors about HDF attributes. I've  
> > > called H5Aclose and I get errors about the argument not being an attribute.  
> > > Turns out the variable I passed was never initialized. So in that case it's  
> > > helpful.
> > > 
> > > One thing to realize is that the error is most likely NOT reading in the  
> > > library itself. I recommend that you use a debugger like GDB to find  
> > > exactly what you are passing into the function and to see if every value  
> > > you're passing in makes sense. That's really the only way to go about it.
> > > 
> > > It all comes down to this: H5Fopen is failing and there are a finite  
> > > number of issues we can address.
> > > 
> > > 1. Does the file exist, and if so are you providing the correct path to  
> > > it (relative or absolute)? Do you have read/write permission for the file?  
> > > 2. Have you misspelled the file?  
> > > 3. Are you providing either DF\_ACC\_RDWR or DF\_ACC\_RDONLY to the second  
> > > argument? Only those two arguments are valid.  
> > > 4. What file access property list are you providing? You should be able  
> > > to rule out providing a buggy access property by just passing in the  
> > > default parameter.
> > > 
> > > I guarantee that your error lies in one of these issues. I recommend you  
> > > make the second and third arguments the read only and default respectively.  
> > > That will isolate the problem to your first argument and whether or not you  
> > > have appropriate file permissions.
> > > 
> > > Regards,  
> > > Landon
> > > 
> > > On Nov 28, 2016 3:33 PM, "Miller, Mark C." \<miller86@llnl.gov\> wrote:
> > > 
> > > > "Hdf-forum on behalf of Rob Latham" wrote:
> > > > 
> > > > 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:
> > > > 
> > > > HDF5-DIAG: Error detected in HDF5 (1.8.16) thread 0:  
> > > > &nbsp;&nbsp;&nbsp;#000: ../../../hdf5-1.8.16/src/H5F.c line 604 in H5Fopen(): unable to  
> > > > open file  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > > > &nbsp;&nbsp;&nbsp;#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  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file  
> > > > &nbsp;&nbsp;&nbsp;#002: ../../../hdf5-1.8.16/src/H5FD.c line 993 in H5FD\_open(): open  
> > > > failed  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: Virtual File Layer  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to initialize object  
> > > > &nbsp;&nbsp;&nbsp;#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  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;major: File accessibilty  
> > > > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minor: Unable to open file
> > > > 
> > > > I am not sure how other users feel about this and it may not even be the  
> > > > original poster's ( Elvis Stansvik) complaint but a big challenge I have  
> > > > with interpreting HDF5 errors \*is\* the "...screenfuls of information".
> > > > 
> > > > It is challenging to paw through it to discover the root cause.
> > > > 
> > > > For example, in the above error stack, we get information about why sec2  
> > > > VFD failed..."errno=13 ("Permission enied") but what are 'flags' and  
> > > > 'o\_flags' there? Are these params to sec2 open call? That has only an  
> > > > 'oflag' argument and not an additional 'flags' argument. And, their numeric  
> > > > values, '1' and '2' are too informatvie either. What about similar info at  
> > > > the HDF5 public interface (e.g. H5Fopen)? What was passed for 'flags'  
> > > > there. Oh, maybe 'flags' in the #003 trace \*is\* the 'flags' argument caller  
> > > > passed to H5Fopen and 'o\_flags' is what HDF5 lib passed to sec2 open call?  
> > > > I could see having 'flags' emitted in the #000 trace if that is indeed the  
> > > > argument passed as 'flags' to H5Fopen. and 'oflags' not 'o\_flags' emitted  
> > > > in the #003 trace. Finally, it would be \*much\* more helpful to see the  
> > > > symbolic constants for the flags and not their numerics.
> > > > 
> > > > So, I personally find grocking HDF5 error stack output very awkward.
> > > > 
> > > > It may be that it is awkward enough for others that no one really is  
> > > > able to find the information they needed in it (e.g. the signal to noise  
> > > > ratio is just way too low).
> > > > 
> > > > My two cents.
> > > > 
> > > > Mark
> > > > 
> > > > --  
> > > > Mark C. Miller, LLNL
> > > > 
> > > > "In the end, we will remember not the words of  
> > > > our enemies but the silence of our friends" - MLK
> > > > 
> > > > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> > > > Hdf-forum is for HDF software users discussion.  
> > > > Hdf-forum@lists.hdfgroup.org  
> > > > [http://lists.hdfgroup.org/mailman/listinfo/hdf-forum\_lists.hdfgroup.org](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > > > Twitter: [x.com](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > Twitter: [x.com](https://twitter.com/hdf5)

---

<div class="post-metadata">

**Author:** ![elvis.stansvik](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@elvis.stansvik](https://forum.hdfgroup.org/u/elvis.stansvik)\
**Post date:** [November 29, 2016, 4:41pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/10 "2016-11-29T16:41:34Z")

</div>

> 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.

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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)

> \> \>\> Twitter: [x.com](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)

> **···**
>
> 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: [x.com](https://twitter.com/hdf5)  
> > \> \>  
> > \>

---

<div class="post-metadata">

**Author:** ![elvis.stansvik](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@elvis.stansvik](https://forum.hdfgroup.org/u/elvis.stansvik)\
**Post date:** [November 29, 2016, 5:07pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/11 "2016-11-29T17:07:22Z")

</div>

> \>  
> \> 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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)

> \> \> \>\> Twitter: [x.com](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](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: [x.com](https://twitter.com/hdf5)  
> > \> \> \>  
> > \> \>  
> > \>  
> > \>

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [November 29, 2016, 9:45pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/12 "2016-11-29T21:45:02Z")

</div>

One thing to keep in mind, and the JNI code does, is that you clear the error stack when you use certain H5E APIs.

Allen

> **···**
>
> On Tuesday, November 29, 2016 6:07:22 PM CST Elvis Stansvik wrote:
> 
> > 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\>:  
> > \> \>  
> > \> \> 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  
> > \> \>  
> > \> \> On Tuesday, November 29, 2016 9:20:03 AM CST Elvis Stansvik wrote:  
> > \> \> \> Hi Rob,  
> > \> \> \>  
> > \> \> \> 2016-11-28 21:43 GMT+01:00 Rob Latham \<robl@mcs.anl.gov\>:  
> > \> \> \>  
> > \> \> \> \>  
> > \> \> \> \>  
> > \> \> \> \> On 11/08/2016 01:18 PM, Elvis Stansvik wrote:  
> > \> \> \> \>  
> > \> \> \> \>\> 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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > \> \> \> \>\> Twitter: [x.com](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > \> \> \> \> Twitter: [x.com](https://twitter.com/hdf5)  
> > \> \> \> \>  
> > \> \> \>  
> > \> \>  
> > \> \>

---

<div class="post-metadata">

**Author:** ![elvis.stansvik](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/e/46a35a/32.png) [@elvis.stansvik](https://forum.hdfgroup.org/u/elvis.stansvik)\
**Post date:** [November 29, 2016, 9:56pm UTC](https://forum.hdfgroup.org/t/more-informative-error-from-h5fopen/3912/13 "2016-11-29T21:56:31Z")

</div>

> One thing to keep in mind, and the JNI code does, is that you clear the

error stack when you use certain H5E APIs.

Thanks for the heads up. Will proceed with care.

Elvis

> Allen
> 
> \> Den 29 nov. 2016 5:41 em skrev "Elvis Stansvik" \<  
> \> elvis.stansvik@orexplore.com\>:  
> \> \>  
> \> \> \>  
> \> \> \> 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():

> **···**
>
> Den 29 nov. 2016 10:45 em skrev "Allen Byrne" \<byrn@hdfgroup.org\>:
> 
> > On Tuesday, November 29, 2016 6:07:22 PM CST Elvis Stansvik wrote:  
> > \> \> 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:  
> > \> 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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > \> \> \> \> \>\> Twitter: [x.com](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](http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org)  
> > \> \> \> \> \> Twitter: [x.com](https://twitter.com/hdf5)  
> > \> \> \> \> \>  
> > \> \> \> \>  
> > \> \> \>  
> > \> \> \>  
> > \>
