public YAMLException(JsonParser p, org.yaml.snakeyaml.error.YAMLException src) { super(p, src.getMessage(), src); }
public YAMLException(JsonParser p, org.yaml.snakeyaml.error.YAMLException src) { super(p, src.getMessage(), src); }
/** * Handle YAML related exceptions by printing out appropriate error message and exiting. */ public static void handleYAMLException(YAMLException exception) { System.err.println("Error parsing .tailor.yml:"); System.err.println(exception.getMessage()); System.exit(ExitCode.failure()); }
@Override @Signature public Memory format(Environment env, Memory... args) { try { return StringMemory.valueOf(yaml.dump(Memory.unwrap(env, args[0], true))); } catch (YAMLException e) { env.exception(ProcessorException.class, e.getMessage()); return Memory.NULL; } }
@Override @Signature public Memory formatTo(Environment env, Memory... args) { try { yaml.dump( Memory.unwrap(env, args[0], true), new OutputStreamWriter(Stream.getOutputStream(env, args[1]), env.getDefaultCharset()) ); return Memory.NULL; } catch (YAMLException e) { env.exception(ProcessorException.class, e.getMessage()); return Memory.NULL; } } }
@Override @Signature public Memory parse(Environment env, Memory... args) { try { if (args[0].instanceOf(Stream.class)) { return Memory.wrap(env, yaml.load(Stream.getInputStream(env, args[0]))); } else { return Memory.wrap(env, yaml.load(args[0].toString())); } } catch (YAMLException e) { env.exception(ProcessorException.class, e.getMessage()); return Memory.NULL; } }
public YAMLException(JsonParser p, org.yaml.snakeyaml.error.YAMLException src) { super(p, src.getMessage(), src); }
public YAMLException(JsonParser p, org.yaml.snakeyaml.error.YAMLException src) { super(p, src.getMessage(), src); }
private static String formatYamlExceptionMessage(Resource res, YAMLException ye) { final StringBuilder sb = new StringBuilder(); sb.append("YAML parsing error in ").append(res); if (ye instanceof MarkedYAMLException) { final Mark mark = ((MarkedYAMLException) ye).getProblemMark(); final String snippet = mark != null ? mark.get_snippet() : null; final String problem = ((MarkedYAMLException) ye).getProblem(); if (mark != null) { sb.append(" at line ").append(mark.getLine()).append(", column ").append(mark.getColumn()); } if (snippet != null) { sb.append(":\n"); sb.append(snippet); } if (problem != null) { // TODO SnakeYaml tends to be a bit nasty about this "problem", e.g org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens() prints the actual char THEN it's representation, so you end up with a big fat actual tab in the message instead of JUST \t(TAB) // See https://code.google.com/p/snakeyaml/issues/detail?id=209 sb.append(": ").append(problem.replaceAll("\\s*\\t\\s*", " ")); } } else { sb.append(": ").append(ye.getMessage()); } return sb.toString(); } }
logger.warn(e.getMessage() + " -- Ignoring."); } catch (YAMLException e) { logger.warn(e.getMessage() + " -- Ignoring.");
public Config loadConfig(URL url) throws ConfigurationException { try { logger.debug("Loading settings from {}", url); byte[] configBytes; try (InputStream is = url.openStream()) { configBytes = ByteStreams.toByteArray(is); } catch (IOException e) { // getStorageConfigURL should have ruled this out throw new AssertionError(e); } Constructor constructor = new CustomConstructor(Config.class); PropertiesChecker propertiesChecker = new PropertiesChecker(); constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Config result = loadConfig(yaml, configBytes); propertiesChecker.check(); return result; } catch (YAMLException e) { throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR + " Error: " + e.getMessage(), false); } }
public Config loadConfig(URL url) throws ConfigurationException { try { logger.debug("Loading settings from {}", url); byte[] configBytes; try (InputStream is = url.openStream()) { configBytes = ByteStreams.toByteArray(is); } catch (IOException e) { // getStorageConfigURL should have ruled this out throw new AssertionError(e); } Constructor constructor = new CustomConstructor(Config.class); PropertiesChecker propertiesChecker = new PropertiesChecker(); constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Config result = loadConfig(yaml, configBytes); propertiesChecker.check(); return result; } catch (YAMLException e) { throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR + " Error: " + e.getMessage(), false); } }
private static boolean tryCreateSensibleParseError(YAMLException e, int depth) { if (depth > 20) { return false; } if (e != null) { if (e.getCause() == null) { if (e.getMessage().contains("Unable to find property 'lib'")) { require(false, "Could not parse manifest. " + "The field 'lib' could not be created. Should it be 'libs'?"); return true; } } else { return tryCreateSensibleParseError((YAMLException) e.getCause(), depth + 1); } } return false; }
public Config loadConfig(URL url) throws ConfigurationException { try { logger.debug("Loading settings from {}", url); byte[] configBytes; try (InputStream is = url.openStream()) { configBytes = ByteStreams.toByteArray(is); } catch (IOException e) { // getStorageConfigURL should have ruled this out throw new AssertionError(e); } Constructor constructor = new CustomConstructor(Config.class); PropertiesChecker propertiesChecker = new PropertiesChecker(); constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Config result = loadConfig(yaml, configBytes); propertiesChecker.check(); return result; } catch (YAMLException e) { throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR + " Error: " + e.getMessage(), false); } }
logger.warn(e.getMessage() + " -- Ignoring."); } catch (YAMLException e) { logger.warn(e.getMessage() + " -- Ignoring.");
public Config loadConfig(URL url) throws ConfigurationException { try { logger.debug("Loading settings from {}", url); byte[] configBytes; try (InputStream is = url.openStream()) { configBytes = ByteStreams.toByteArray(is); } catch (IOException e) { // getStorageConfigURL should have ruled this out throw new AssertionError(e); } Constructor constructor = new CustomConstructor(Config.class); PropertiesChecker propertiesChecker = new PropertiesChecker(); constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Config result = loadConfig(yaml, configBytes); propertiesChecker.check(); return result; } catch (YAMLException e) { throw new ConfigurationException("Invalid yaml: " + url + SystemUtils.LINE_SEPARATOR + " Error: " + e.getMessage(), false); } }
errorMessage.add(createErrorResult(ex.getMessage()));
errorMessage.add(createErrorResult(ex.getMessage()));
throw new ParserException("YAML parse exception: " + e.getMessage(), node, e);