Skip to content

Commit

Permalink
Use GenericRuntimeException instead of RuntimeException
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens committed Oct 21, 2024
1 parent a3398de commit fb7ba52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ private void initializeReader() {
InputStream inputStream = url.openStream();
reader = factory.createXMLStreamReader( inputStream );

while (reader.hasNext() && reader.next() != XMLStreamConstants.START_ELEMENT);
while ( reader.hasNext() && reader.next() != XMLStreamConstants.START_ELEMENT )
;
rootElementName = reader.getLocalName();
if(!reader.hasNext()) {
if ( !reader.hasNext() ) {
throw new GenericRuntimeException( "Unexpected end of stream" );
}
do {
if (!reader.hasNext()) {
if ( !reader.hasNext() ) {
return;
}
reader.next();
} while (reader.getEventType() != XMLStreamConstants.START_ELEMENT );
} while ( reader.getEventType() != XMLStreamConstants.START_ELEMENT );
} catch ( XMLStreamException | IOException e ) {
throw new GenericRuntimeException( "Error initializing XML reader: " + e.getMessage(), e );
}
Expand All @@ -66,23 +67,22 @@ public boolean moveNext() {
String documentOuterName = reader.getLocalName();
reader.next();
current = new PolyValue[]{ converter.toPolyDocument( reader, documentOuterName ) };
if (!reader.hasNext() ) {
if ( !reader.hasNext() ) {
return false;
}
if (reader.next() == XMLStreamConstants.END_ELEMENT && rootElementName.equals( reader.getLocalName())) {
if ( reader.next() == XMLStreamConstants.END_ELEMENT && rootElementName.equals( reader.getLocalName() ) ) {
return false;
}
while (reader.getEventType() != XMLStreamConstants.START_ELEMENT ) {
if (!reader.hasNext()) {
while ( reader.getEventType() != XMLStreamConstants.START_ELEMENT ) {
if ( !reader.hasNext() ) {
return false;
}
reader.next();
}
return true;
} catch ( XMLStreamException | DecoderException e ) {
throw new RuntimeException( "Filed to get next document.", e );
throw new GenericRuntimeException( "Filed to get next document.", e );
}

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.xml.stream.XMLStreamReader;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.polypheny.db.catalog.exceptions.GenericRuntimeException;
import org.polypheny.db.type.entity.PolyBinary;
import org.polypheny.db.type.entity.PolyBoolean;
import org.polypheny.db.type.entity.PolyList;
Expand Down Expand Up @@ -114,7 +115,7 @@ public PolyValue toPolyValue( XMLStreamReader reader ) throws XMLStreamException
yield new PolyBinary( hexBinaryData, hexBinaryData.length );
}
case "string" -> new PolyString( value );
default -> throw new RuntimeException( "Illegal type encountered: " + typeName );
default -> throw new GenericRuntimeException( "Illegal type encountered: " + typeName );
};
}

Expand Down

0 comments on commit fb7ba52

Please sign in to comment.