[jOOQ/jOOQ#8900] Extract MiniJAXB common exception handling logic
`marshal()` and `unmarshal()` now share the same exception handling.
This commit is contained in:
parent
bcdadee556
commit
eee38f618c
@ -113,19 +113,7 @@ public class MiniJAXB {
|
||||
return;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
if (t instanceof Error) {
|
||||
ExceptionTools.sneakyThrow(t);
|
||||
}
|
||||
else if (ExceptionTools.getCause(t, ClassNotFoundException.class) != null ||
|
||||
ExceptionTools.getCause(t, Error.class) != null) {
|
||||
jaxbAvailable = false;
|
||||
log.debug("JAXB is not available from the classpath / module path");
|
||||
}
|
||||
else {
|
||||
jaxbAvailable = true;
|
||||
log.debug("JAXB is available from the classpath / module path");
|
||||
throw new ConfigurationException("Error while reading xml", t);
|
||||
}
|
||||
handleJaxbException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,6 +132,24 @@ public class MiniJAXB {
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleJaxbException(Throwable t) {
|
||||
if (t instanceof Error) {
|
||||
jaxbAvailable = true;
|
||||
log.debug("JAXB is available from the classpath / module path");
|
||||
ExceptionTools.sneakyThrow(t);
|
||||
}
|
||||
else if (ExceptionTools.getCause(t, ClassNotFoundException.class) != null ||
|
||||
ExceptionTools.getCause(t, Error.class) != null) {
|
||||
jaxbAvailable = false;
|
||||
log.debug("JAXB is not available from the classpath / module path");
|
||||
}
|
||||
else {
|
||||
jaxbAvailable = true;
|
||||
log.debug("JAXB is available from the classpath / module path");
|
||||
throw new ConfigurationException("Error while reading xml", t);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T unmarshal(InputStream in, Class<T> type) {
|
||||
return unmarshal0(new InputSource(in), type);
|
||||
}
|
||||
@ -174,19 +180,7 @@ public class MiniJAXB {
|
||||
return result;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
if (t instanceof Error) {
|
||||
ExceptionTools.sneakyThrow(t);
|
||||
}
|
||||
if (ExceptionTools.getCause(t, ClassNotFoundException.class) != null ||
|
||||
ExceptionTools.getCause(t, Error.class) != null) {
|
||||
jaxbAvailable = false;
|
||||
log.debug("JAXB is not available from the classpath / module path");
|
||||
}
|
||||
else {
|
||||
jaxbAvailable = true;
|
||||
log.debug("JAXB is available from the classpath / module path");
|
||||
throw new ConfigurationException("Error while reading xml", t);
|
||||
}
|
||||
handleJaxbException(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user