Commit 10d2f671 authored by Ryan Berkheimer's avatar Ryan Berkheimer
Browse files

Added new custom exception. We need to replace all 'System.stop' calls with...

Added new custom exception. We need to replace all 'System.stop' calls with thrown exceptions - do not want to kill JVM since this is a user lib.
parent 59ecf6b8
......@@ -8,6 +8,7 @@ import java.util.AbstractMap;
import java.util.stream.Collectors;
import gov.noaa.messageapi.parsers.protocols.MetadataParser;
import gov.noaa.messageapi.exceptions.ConfigurationParsingException;
import gov.noaa.messageapi.parsers.protocols.ConnectionParser;
import gov.noaa.messageapi.parsers.protocols.EndpointParser;
import gov.noaa.messageapi.utils.general.ListUtils;
......@@ -54,6 +55,7 @@ public class ProtocolDefinition {
* @param endpointSpec A spec that is used to determine how to parse the session endpoints, either through a path or a direct map
* @throws Exception
*/
@SuppressWarnings("unchecked")
private void parseEndpoints(Object endpoints) throws Exception {
this.endpointMap = new HashMap<String,List<Map<String,Object>>>();
try {
......@@ -67,12 +69,12 @@ public class ProtocolDefinition {
System.exit(1);
}
} catch (Exception e) {
System.out.println("The endpoint specification was an invalid data structure Needs to be list or map.");
System.err.println("The protocol layer must contain a valid endpoint. Ending session building now.");
System.exit(1);
throw new ConfigurationParsingException(
"The protocol layer must contain a valid endpoint. Ending session building now.", e);
}
}
@SuppressWarnings("unchecked")
private void parseEndpointsFromSpec(String endpointSpec) throws Exception {
EndpointParser endpointParser = new EndpointParser(endpointSpec);
ListUtils.removeAllNulls(endpointParser.getEndpointMaps().stream().map(endpointMap -> {
......
package gov.noaa.messageapi.exceptions;
import java.lang.Exception;
public class ConfigurationParsingException extends Exception {
/**
* Required (generated) serial version ID for serializable class
*/
private static final long serialVersionUID = 6896902577211242022L;
public ConfigurationParsingException(String message, Throwable err) {
super(message, err);
}
public ConfigurationParsingException(String message) {
super(message);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment