Java 类org.yaml.snakeyaml.parser.ParserException 实例源码

项目:wildfly-swarm    文件:ConfigReader.java   
public MetadataList readConfig(String mappingFile) {
    try {


        File file = new File(mappingFile);
        log.info("Loading mapping file from " + file.getAbsolutePath());
        InputStream configStream = new FileInputStream(file);

        return readConfig(configStream);
    } catch (FileNotFoundException e) {
        log.warn("No configuration found");
    } catch (ParserException pe) {
        log.error(pe);
    }
    return null;
}
项目:spring4-understanding    文件:YamlProcessor.java   
@Override
protected Map<Object, Object> constructMapping(MappingNode node) {
    try {
        return super.constructMapping(node);
    }
    catch (IllegalStateException ex) {
        throw new ParserException("while parsing MappingNode",
                node.getStartMark(), ex.getMessage(), node.getEndMark());
    }
}
项目:spring4-understanding    文件:YamlProcessorTests.java   
@Test
public void testBadDocumentStart() throws Exception {
    this.processor.setResources(new ByteArrayResource(
            "foo # a document\nbar: baz".getBytes()));
    this.exception.expect(ParserException.class);
    this.exception.expectMessage("line 2, column 1");
    this.processor.process(new MatchCallback() {
        @Override
        public void process(Properties properties, Map<String, Object> map) {
        }
    });
}
项目:spring4-understanding    文件:YamlPropertiesFactoryBeanTests.java   
@Test
public void testLoadResourcesWithInternalOverride() throws Exception {
    YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
    factory.setResources(new ByteArrayResource(
            "foo: bar\nspam:\n  foo: baz\nfoo: bucket".getBytes()));
    exception.expect(ParserException.class);
    factory.getObject();
}
项目:rug-resolver    文件:ManifestReader.java   
private Iterable<Object> readYaml(Option<FileArtifact> manifestFile) {
    try {
        Yaml yaml = new Yaml();
        return (Iterable<Object>) yaml.loadAll(manifestFile.get().content());
    }
    catch (ParserException e) {
        throw new ManifestParsingException("manifest.yml file in .atomist is malformed:\n\n%s",
                e.getMessage());
    }
}
项目:appengine-plugins-core    文件:CloudSdkAppEngineFlexibleStaging.java   
@VisibleForTesting
static String findRuntime(StageFlexibleConfiguration config) throws IOException {
  try {
    // verification for app.yaml that contains runtime:java
    Path appYaml = config.getAppEngineDirectory().toPath().resolve(APP_YAML);
    return new AppYaml(appYaml).getRuntime();
  } catch (ScannerException | ParserException ex) {
    throw new AppEngineException("Malformed 'app.yaml'.", ex);
  }
}
项目:spring    文件:YamlProcessor.java   
@Override
protected Map<Object, Object> constructMapping(MappingNode node) {
    try {
        return super.constructMapping(node);
    }
    catch (IllegalStateException ex) {
        throw new ParserException("while parsing MappingNode",
                node.getStartMark(), ex.getMessage(), node.getEndMark());
    }
}
项目:java-dynamicconfig    文件:YamlDeserializer.java   
/**
 * {@inheritDoc}
 */
@Override
public ConfigurationResult deserialize(InputStream input) throws ConfigurationException {
    String content = new Scanner(input).useDelimiter("\\A").next();

    HierarchicalConfiguration configuration = new HierarchicalConfiguration();
    List<IncludeReference> includes = new ArrayList<>();
    if (!content.isEmpty()) {
        Object tree;
        try {
            tree = yaml.load(content);
        } catch (ParserException e) {
            throw new ConfigurationException("Failed to parse input as valid YAML.", e);
        }
        traverseTreeAndLoad(configuration.getRootNode(), null, includes, tree);

        // Get the references from the special 'extends' key.
        for (String reference : configuration.getStringArray("extends")) {
            includes.add(new IncludeReference(reference));
        }
    }

    return new ConfigurationResult(configuration, includes);
}
项目:KaiZen-OpenAPI-Editor    文件:YamlErrorProcessor.java   
public String rewriteMessage(YAMLException exception) {
    if (exception instanceof ParserException) {
        if ("while parsing a block mapping".equals(((ParserException) exception).getContext())) {
            return Messages.error_yaml_parser_indentation;
        }
    }
    return exception != null ? exception.getLocalizedMessage() : null;
}
项目:spring4-understanding    文件:YamlMapFactoryBeanTests.java   
@Test(expected = ParserException.class)
public void testDuplicateKey() throws Exception {
    this.factory.setResources(new ByteArrayResource[] {new ByteArrayResource(
            "mymap:\n  foo: bar\nmymap:\n  bar: foo".getBytes())});
    this.factory.getObject().get("mymap");
}
项目:halyard    文件:ParseConfigException.java   
public ParseConfigException(ParserException e) {
  Problem problem = new ConfigProblemBuilder(Problem.Severity.FATAL,
      "Could not parse your halconfig: " + e.getMessage()).build();
  getProblems().add(problem);
}