本文整理汇总了Java中org.yaml.snakeyaml.constructor.ConstructorException类的典型用法代码示例。如果您正苦于以下问题:Java ConstructorException类的具体用法?Java ConstructorException怎么用?Java ConstructorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConstructorException类属于org.yaml.snakeyaml.constructor包,在下文中一共展示了ConstructorException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getErrorMessage
import org.yaml.snakeyaml.constructor.ConstructorException; //导入依赖的package包/类
public String getErrorMessage(Throwable e) {
String errorMessage = e.getMessage();
if (e instanceof ScannerException &&
(errorMessage.startsWith(MAPPING_VALUES_NOT_ALLOWED_HERE_ERROR) ||
errorMessage.startsWith(SCANNING_A_SIMPLE_KEY_ERROR))) {
errorMessage += KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG;
} else if (e instanceof ConstructorException && errorMessage.startsWith(CANNOT_CREATE_PROPERTY_ERROR)) {
if (errorMessage.contains(UNABLE_TO_FIND_PROPERTY_ERROR)) {
//parse for undefined property name
String truncatedErrorMessage = errorMessage.substring(errorMessage.indexOf(TRUNCATION_BEGINNING),
errorMessage.indexOf(TRUNCATION_END));
String undefinedProperty = truncatedErrorMessage.substring(truncatedErrorMessage.indexOf("\'") + 1,
truncatedErrorMessage.lastIndexOf("\'"));
errorMessage += "Property \'" + undefinedProperty + "\' is not supported by CloudSlang. Check that \'" +
undefinedProperty + "\' is indented properly.";
} else if (errorMessage.contains(MAP_CONSTRUCTOR_NOT_FOUND_ERROR)) {
errorMessage += KEY_VALUE_PAIR_MISSING_OR_INDENTATION_PROBLEM_MSG;
}
}
return errorMessage;
}
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:23,代码来源:ParserExceptionHandler.java
示例2: testStringCharArray
import org.yaml.snakeyaml.constructor.ConstructorException; //导入依赖的package包/类
public void testStringCharArray() {
Yaml yaml = new Yaml();
try {
yaml.load(pkg + ".CharArr [ [ abcd ] ]");
fail("Expected exception.");
} catch (Exception e) {
assertEquals(ConstructorException.class, e.getClass());
assertEquals("Invalid node Character: 'abcd'; length: 4", e.getCause().getMessage());
}
}
开发者ID:bmoliveira,项目名称:snake-yaml,代码行数:12,代码来源:PrimitiveArrayTest.java
示例3: testYamlThrowsConstructorExceptionShouldThrowIllegalArgumentException
import org.yaml.snakeyaml.constructor.ConstructorException; //导入依赖的package包/类
@Test
public void testYamlThrowsConstructorExceptionShouldThrowIllegalArgumentException() {
Yaml mockYaml = mock(Yaml.class);
when(mockYaml.loadAs(anyString(), Matchers.<Class<Object>>anyObject())).thenThrow(ConstructorException.class);
reader.setYaml(mockYaml);
reader.read(User.class);
}
开发者ID:lucassaldanha,项目名称:playdoh,代码行数:9,代码来源:YamlModelReaderTest.java
示例4: shouldThrowExceptionWhenCannotLoadSettings
import org.yaml.snakeyaml.constructor.ConstructorException; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenCannotLoadSettings() throws IOException {
shouldLoadWithError(FileNotFoundException.class);
FileUtils.writeStringToFile(settingsFile, "something weird");
shouldLoadWithError(ConstructorException.class);
settings.save();
settingsFile.setReadable(false);
shouldLoadWithError(FileNotFoundException.class);
}
开发者ID:mezuro,项目名称:kalibro,代码行数:12,代码来源:SettingsAcceptanceTest.java
示例5: testReadYamlFromResource_badResource
import org.yaml.snakeyaml.constructor.ConstructorException; //导入依赖的package包/类
@Test(expected = ConstructorException.class)
public void testReadYamlFromResource_badResource() {
YamlUtils.readChatAlyticsConfig("config/bad-config.yaml");
}
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:5,代码来源:YamlUtilsTest.java
示例6: readBadVersion
import org.yaml.snakeyaml.constructor.ConstructorException; //导入依赖的package包/类
@Test(expected = ConstructorException.class)
public void readBadVersion() throws ConfigurationException, UnsupportedEncodingException, IOException {
try (Reader in = new InputStreamReader(getClass().getResourceAsStream("/srcdeps-bad-version.yaml"), "utf-8")) {
new YamlConfigurationIo().read(in);
}
}
开发者ID:srcdeps,项目名称:srcdeps-core,代码行数:7,代码来源:YamlConfigurationIoTest.java
注:本文中的org.yaml.snakeyaml.constructor.ConstructorException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论