当前位置: 首页>>代码示例>>Java>>正文


Java YAMLException.getMessage方法代码示例

本文整理汇总了Java中org.yaml.snakeyaml.error.YAMLException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java YAMLException.getMessage方法的具体用法?Java YAMLException.getMessage怎么用?Java YAMLException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.yaml.snakeyaml.error.YAMLException的用法示例。


在下文中一共展示了YAMLException.getMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBean2

import org.yaml.snakeyaml.error.YAMLException; //导入方法依赖的package包/类
public void testBean2() {
    IncompleteBean bean = new IncompleteBean();
    bean.setName("lunch");
    DumperOptions options = new DumperOptions();
    options.setAllowReadOnlyProperties(true);
    Yaml yaml = new Yaml(options);
    String output = yaml.dumpAsMap(bean);
    // System.out.println(output);
    assertEquals("id: 10\nname: lunch\n", output);
    //
    Yaml loader = new Yaml();
    try {
        loader.loadAs(output, IncompleteBean.class);
        fail("Setter is missing.");
    } catch (YAMLException e) {
        String message = e.getMessage();
        assertTrue(
                message,
                message.contains("Unable to find property 'id' on class: org.yaml.snakeyaml.issues.issue47.IncompleteBean"));
    }
}
 
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:22,代码来源:ReadOnlyPropertiesTest.java

示例2: readYamlFile

import org.yaml.snakeyaml.error.YAMLException; //导入方法依赖的package包/类
Map<String, Object> readYamlFile(String yamlfile) throws FileNotFoundException {
    File file = new File(yamlfile);
    if (file.exists()) {
        InputStream input = new FileInputStream(file);
        Yaml yaml = new Yaml();
        Object data;
        try {
            data = yaml.load(input);
        } catch (YAMLException ye) {
            throw new PivioYamlParserException("Data in " + yamlfile + " is not valid: "+ye.getMessage());
        }
        if (data instanceof Map) {
            return makeLowerCaseKeys((Map<String, Object>) data);
        } else {
            throw new PivioYamlParserException("Data in " + yamlfile + " is not valid.");
        }
    } else {
        throw new FileNotFoundException("Could not find " + yamlfile + ".");
    }
}
 
开发者ID:pivio,项目名称:pivio-client,代码行数:21,代码来源:Reader.java

示例3: buildFromYml

import org.yaml.snakeyaml.error.YAMLException; //导入方法依赖的package包/类
/**
 * Verify and create node tree by yml
 *
 * @param yml raw yml string
 * @return root node of yml
 * @throws YmlException if yml format is illegal
 */
public static Node buildFromYml(String yml, String rootName) {
    try {
        Yaml yaml = new Yaml(ROOT_YML_CONSTRUCTOR);
        RootYmlWrapper node = yaml.load(yml);

        // verify flow node
        if (Objects.isNull(node.flow)) {
            throw new YmlException("The 'flow' content must be defined");
        }

        // current version only support single flow
        if (node.flow.size() > 1) {
            throw new YmlException("Unsupported multiple flows definition");
        }

        // steps must be provided
        List<NodeWrapper> steps = node.flow.get(0).steps;
        if (Objects.isNull(steps) || steps.isEmpty()) {
            throw new YmlException("The 'step' must be defined");
        }

        node.flow.get(0).name = rootName;
        Node root = node.flow.get(0).toNode();

        buildNodeRelation(root);
        VALIDATOR.validate(root);

        return root;
    } catch (YAMLException e) {
        throw new YmlException(e.getMessage());
    }
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:40,代码来源:NodeUtil.java


注:本文中的org.yaml.snakeyaml.error.YAMLException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。