Obtaining H5E_NOTFOUND error code from H5Aopen

'Morning,

I've noticed (from trying it and then reading the 1.8.7 source in
H5A.c) that H5Aopen seemingly never returns H5E_NOTFOUND. The logic
that I suspect should return H5E_NOTFOUND instead returns
H5E_CANTINIT:

    /* Read in attribute from object header */
    if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name,
H5AC_ind_dxpl_id)))
        HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load
attribute info from object header")

Should that HGOTO_ERROR line employ H5E_NOTFOUND? How about the one
following it commented with "Finish initializing attribute"? Otherwise
a caller of H5Aopen cannot distinguish between a non-existent
attribute and other sorts of errors without an auxiliary call to
H5Aexists...

Thanks,
Rhys

Hi Rhys,

···

On Sep 14, 2011, at 10:12 AM, Rhys Ulerich wrote:

'Morning,

I've noticed (from trying it and then reading the 1.8.7 source in
H5A.c) that H5Aopen seemingly never returns H5E_NOTFOUND. The logic
that I suspect should return H5E_NOTFOUND instead returns
H5E_CANTINIT:

   /* Read in attribute from object header */
   if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name,
H5AC_ind_dxpl_id)))
       HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load
attribute info from object header")

Should that HGOTO_ERROR line employ H5E_NOTFOUND? How about the one
following it commented with "Finish initializing attribute"? Otherwise
a caller of H5Aopen cannot distinguish between a non-existent
attribute and other sorts of errors without an auxiliary call to
H5Aexists...

  Yes, we should tweak that, but really it's best to use H5Aexists first, if the application isn't certain that the attribute should exist. Making the application parse the error stack is prone to complexity and possible misinterpretation (as you note! :-).

  Quincey

Hi Quincey,

Thanks for the very quick response.

I've noticed (from trying it and then reading the 1.8.7 source in
H5A.c) that H5Aopen seemingly never returns H5E_NOTFOUND. The logic
that I suspect should return H5E_NOTFOUND instead returns
H5E_CANTINIT...

   Yes, we should tweak that, but really it's best to use H5Aexists first,

if the application isn't certain that the attribute should exist.

True, but it is nice to pay for the existence check overhead only in
the uncommon failure case (though I expect the overhead to be
miniscule). I'll use H5Aexists in my logic to clarify the situation
after H5Aopen has balked.

FWIW, H5Aopen_by_name exhibits different behavior from H5Aopen but
also does not return H5E_NOTFOUND.

- Rhys