Skip to content

Commit

Permalink
Consistent (SAX/DOM) wrapping of XML parse errors
Browse files Browse the repository at this point in the history
The logic that chooses wrapping SQLException subclass and SQLstate
for XML parse exceptions and I/O exceptions in XMLCopier.saxCopy
is now duplicated in AdjustingDOMSource.get.

Addresses issue #481.
  • Loading branch information
jcflack committed Mar 31, 2024
1 parent 38e46db commit e77d11a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions pljava/src/main/java/org/postgresql/pljava/jdbc/SQLXMLImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3933,6 +3933,10 @@ static void saxCopy(SAXSource sxs, SAXResult sxr) throws SQLException
SAX2PROPERTY.LEXICAL_HANDLER.propertyUri(), lh);
xr.parse(sxs.getInputSource());
}
/*
* If changing these wrapping conventions, change them also in
* AdjustingDOMSource.get()
*/
catch ( SAXException e )
{
throw new SQLDataException(e.getMessage(), "22000", e);
Expand Down Expand Up @@ -5555,10 +5559,21 @@ public DOMSource get() throws SQLException
}

Exception e = exceptions();
if ( null != e )
throw normalizedException(e);

return ds;
if ( null == e )
return ds;

/*
* If changing these wrapping conventions, change them also in
* XMLCopier.saxCopy()
*/
if ( e instanceof SAXException )
throw new SQLDataException(e.getMessage(), "22000", e);

if ( e instanceof IOException )
throw new SQLException(e.getMessage(), "58030", e);

throw normalizedException(e);
}

@Override
Expand Down

0 comments on commit e77d11a

Please sign in to comment.