Skip to content

Commit e77d11a

Browse files
committed
Consistent (SAX/DOM) wrapping of XML parse errors
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.
1 parent 38e46db commit e77d11a

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

pljava/src/main/java/org/postgresql/pljava/jdbc/SQLXMLImpl.java

+18-3
Original file line numberDiff line numberDiff line change
@@ -3933,6 +3933,10 @@ static void saxCopy(SAXSource sxs, SAXResult sxr) throws SQLException
39333933
SAX2PROPERTY.LEXICAL_HANDLER.propertyUri(), lh);
39343934
xr.parse(sxs.getInputSource());
39353935
}
3936+
/*
3937+
* If changing these wrapping conventions, change them also in
3938+
* AdjustingDOMSource.get()
3939+
*/
39363940
catch ( SAXException e )
39373941
{
39383942
throw new SQLDataException(e.getMessage(), "22000", e);
@@ -5555,10 +5559,21 @@ public DOMSource get() throws SQLException
55555559
}
55565560

55575561
Exception e = exceptions();
5558-
if ( null != e )
5559-
throw normalizedException(e);
55605562

5561-
return ds;
5563+
if ( null == e )
5564+
return ds;
5565+
5566+
/*
5567+
* If changing these wrapping conventions, change them also in
5568+
* XMLCopier.saxCopy()
5569+
*/
5570+
if ( e instanceof SAXException )
5571+
throw new SQLDataException(e.getMessage(), "22000", e);
5572+
5573+
if ( e instanceof IOException )
5574+
throw new SQLException(e.getMessage(), "58030", e);
5575+
5576+
throw normalizedException(e);
55625577
}
55635578

55645579
@Override

0 commit comments

Comments
 (0)