Search in sources :

Example 6 with ScannerException

use of org.yaml.snakeyaml.scanner.ScannerException in project winery by eclipse.

the class YamlReader method readServiceTemplate.

private YTServiceTemplate readServiceTemplate(Path path, Path file, String namespace) throws MultiException {
    Path filePath;
    if (Objects.isNull(path)) {
        filePath = file;
    } else {
        filePath = path.resolve(file);
    }
    if (!fileChanged(filePath)) {
        if (exceptionBuffer.containsKey(filePath)) {
            throw exceptionBuffer.get(filePath);
        }
        if (serviceTemplateBuffer.containsKey(filePath)) {
            return serviceTemplateBuffer.get(filePath);
        }
    }
    logger.debug("Read Service Template: {}", filePath);
    try {
        // pre parse checking
        try {
            ObjectValidator objectValidator = new ObjectValidator();
            objectValidator.validateObject(readObject(filePath));
        } catch (ConstructorException e) {
            ExceptionInterpreter interpreter = new ExceptionInterpreter();
            throw new MultiException().add(interpreter.interpret(e));
        } catch (ScannerException e) {
            ExceptionInterpreter interpreter = new ExceptionInterpreter();
            throw new MultiException().add(interpreter.interpret(e));
        } catch (YAMLParserException e) {
            throw new MultiException().add(e);
        }
        // parse checking
        YTServiceTemplate result = buildServiceTemplate(readObject(filePath), namespace);
        // post parse checking
        Validator validator = new Validator(path);
        validator.validate(result, namespace);
        serviceTemplateBuffer.put(filePath, result);
        return result;
    } catch (MultiException e) {
        exceptionBuffer.put(filePath, e);
        throw e.add(file.toString());
    }
}
Also used : Path(java.nio.file.Path) ScannerException(org.yaml.snakeyaml.scanner.ScannerException) ExceptionInterpreter(org.eclipse.winery.repository.converter.validator.support.ExceptionInterpreter) YAMLParserException(org.eclipse.winery.model.converter.support.exception.YAMLParserException) YTServiceTemplate(org.eclipse.winery.model.tosca.yaml.YTServiceTemplate) ObjectValidator(org.eclipse.winery.repository.converter.validator.ObjectValidator) ConstructorException(org.yaml.snakeyaml.constructor.ConstructorException) MultiException(org.eclipse.winery.model.converter.support.exception.MultiException) Validator(org.eclipse.winery.repository.converter.validator.Validator) ObjectValidator(org.eclipse.winery.repository.converter.validator.ObjectValidator)

Example 7 with ScannerException

use of org.yaml.snakeyaml.scanner.ScannerException in project sts4 by spring-projects.

the class YamlReconcileEngine method reconcile.

@Override
public void reconcile(IDocument doc, IProblemCollector problemCollector) {
    problemCollector.beginCollecting();
    try {
        YamlFileAST ast = parser.getAST(doc);
        YamlASTReconciler reconciler = getASTReconciler(doc, problemCollector);
        if (reconciler != null) {
            reconciler.reconcile(ast);
        }
    } catch (ParserException e) {
        String msg = e.getProblem();
        Mark mark = e.getProblemMark();
        problemCollector.accept(syntaxError(msg, mark.getIndex(), 1));
    } catch (ScannerException e) {
        String msg = e.getProblem();
        Mark mark = e.getProblemMark();
        problemCollector.accept(syntaxError(msg, mark.getIndex(), 1));
    } catch (Exception e) {
        logger.error("unexpected error during reconcile", e);
    } finally {
        problemCollector.endCollecting();
    }
}
Also used : ScannerException(org.yaml.snakeyaml.scanner.ScannerException) ParserException(org.yaml.snakeyaml.parser.ParserException) YamlFileAST(org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST) Mark(org.yaml.snakeyaml.error.Mark) ParserException(org.yaml.snakeyaml.parser.ParserException) ScannerException(org.yaml.snakeyaml.scanner.ScannerException)

Aggregations

ScannerException (org.yaml.snakeyaml.scanner.ScannerException)7 Path (java.nio.file.Path)3 ConstructorException (org.yaml.snakeyaml.constructor.ConstructorException)3 MultiException (org.eclipse.winery.model.converter.support.exception.MultiException)2 ObjectValidator (org.eclipse.winery.repository.converter.validator.ObjectValidator)2 ExceptionInterpreter (org.eclipse.winery.repository.converter.validator.support.ExceptionInterpreter)2 Yaml (org.yaml.snakeyaml.Yaml)2 ParserException (org.yaml.snakeyaml.parser.ParserException)2 ParseConfigException (com.netflix.spinnaker.halyard.config.error.v1.ParseConfigException)1 Halconfig (com.netflix.spinnaker.halyard.config.model.v1.node.Halconfig)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvalidPathException (java.nio.file.InvalidPathException)1 Map (java.util.Map)1 InvalidToscaSyntax (org.eclipse.winery.model.converter.support.exception.InvalidToscaSyntax)1 YAMLParserException (org.eclipse.winery.model.converter.support.exception.YAMLParserException)1