Skip to content

Commit

Permalink
dom: Stop serialize from always reporting an error
Browse files Browse the repository at this point in the history
The serialize function has an optional exception argument
to catch errors. One of our checks comes from normalising the
document and (at this point) this should only see namespace
errors. If not, we throw an internal error. However, the check
forgot that getException returns 0 if we are not in an exception
and turned the no exception case into an internal error. This is
fixed by checking if we are in an exceptional state before checking
the error code.
  • Loading branch information
andreww committed Jun 5, 2013
1 parent 4cd6af1 commit 4c3522b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions dom/m_dom_utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ subroutine serialize(startNode, name, ex)
call normalizeDocument(startNode, ex)
if (present(ex)) then
! Only possible error should be namespace error ...
if (getExceptionCode(ex)/=NAMESPACE_ERR) then
if (getFoX_checks().or.FoX_INTERNAL_ERROR<200) then
! but we should avoid turning an error of 0 into
! an internal error!
if (inException(ex)) then
if (getExceptionCode(ex)/=NAMESPACE_ERR) then
if (getFoX_checks().or.FoX_INTERNAL_ERROR<200) then
call throw_exception(FoX_INTERNAL_ERROR, "serialize", ex)
if (present(ex)) then
if (inException(ex)) then
Expand All @@ -150,8 +153,8 @@ subroutine serialize(startNode, name, ex)
endif
endif

else
if (getFoX_checks().or.SERIALIZE_ERR<200) then
else
if (getFoX_checks().or.SERIALIZE_ERR<200) then
call throw_exception(SERIALIZE_ERR, "serialize", ex)
if (present(ex)) then
if (inException(ex)) then
Expand All @@ -160,6 +163,7 @@ subroutine serialize(startNode, name, ex)
endif
endif

endif
endif
endif
else
Expand Down
12 changes: 8 additions & 4 deletions dom/m_dom_utils.m4
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ contains
call normalizeDocument(startNode, ex)
if (present(ex)) then
! Only possible error should be namespace error ...
if (getExceptionCode(ex)/=NAMESPACE_ERR) then
TOHW_m_dom_throw_error(FoX_INTERNAL_ERROR)
else
TOHW_m_dom_throw_error(SERIALIZE_ERR)
! but we should avoid turning an error of 0 into
! an internal error!
if (inException(ex)) then
if (getExceptionCode(ex)/=NAMESPACE_ERR) then
TOHW_m_dom_throw_error(FoX_INTERNAL_ERROR)
else
TOHW_m_dom_throw_error(SERIALIZE_ERR)
endif
endif
endif
else
Expand Down

0 comments on commit 4c3522b

Please sign in to comment.