forked from Qortal/qortal
Better logging for settings/blockchain JSON file parsing
This commit is contained in:
parent
deae03f1a4
commit
c7123df79d
@ -11,6 +11,7 @@ import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.UnmarshalException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
@ -19,6 +20,7 @@ import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.eclipse.persistence.exceptions.XMLMarshalException;
|
||||
import org.eclipse.persistence.jaxb.JAXBContextFactory;
|
||||
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
|
||||
import org.qora.data.block.BlockData;
|
||||
@ -132,6 +134,16 @@ public class BlockChain {
|
||||
|
||||
// Attempt to unmarshal JSON stream to BlockChain config
|
||||
blockchain = unmarshaller.unmarshal(json, BlockChain.class).getValue();
|
||||
} catch (UnmarshalException e) {
|
||||
Throwable linkedException = e.getLinkedException();
|
||||
if (linkedException instanceof XMLMarshalException) {
|
||||
String message = ((XMLMarshalException) linkedException).getInternalException().getLocalizedMessage();
|
||||
LOGGER.error(message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
|
||||
LOGGER.error("Unable to process blockchain config file", e);
|
||||
throw new RuntimeException("Unable to process blockchain config file", e);
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.error("Blockchain config file not found: " + filename);
|
||||
throw new RuntimeException("Blockchain config file not found: " + filename);
|
||||
|
@ -8,6 +8,7 @@ import java.io.Reader;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.UnmarshalException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
@ -15,6 +16,7 @@ import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.eclipse.persistence.exceptions.XMLMarshalException;
|
||||
import org.eclipse.persistence.jaxb.JAXBContextFactory;
|
||||
import org.eclipse.persistence.jaxb.UnmarshallerProperties;
|
||||
import org.qora.block.BlockChain;
|
||||
@ -112,6 +114,16 @@ public class Settings {
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.error("Settings file not found: " + path + filename);
|
||||
throw new RuntimeException("Settings file not found: " + path + filename);
|
||||
} catch (UnmarshalException e) {
|
||||
Throwable linkedException = e.getLinkedException();
|
||||
if (linkedException instanceof XMLMarshalException) {
|
||||
String message = ((XMLMarshalException) linkedException).getInternalException().getLocalizedMessage();
|
||||
LOGGER.error(message);
|
||||
throw new RuntimeException(message);
|
||||
}
|
||||
|
||||
LOGGER.error("Unable to process settings file", e);
|
||||
throw new RuntimeException("Unable to process settings file", e);
|
||||
} catch (JAXBException e) {
|
||||
LOGGER.error("Unable to process settings file", e);
|
||||
throw new RuntimeException("Unable to process settings file", e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user