Package com.gatehill.apib.parser.exception

Examples of com.gatehill.apib.parser.exception.ParserException


                }
            }

            if (null != parserHome) {
                if (!parserHome.isDirectory()) {
                    throw new ParserException("Execution directory does not exist: " + parserHome);

                } else if (!parserHome.canRead()) {
                    throw new ParserException("Execution directory is not readable: " + parserHome);
                }

            } else {
                LOGGER.warn("No parser home directory specified");
            }

            final ParsingResult<File> result = executeParser(parserHome, blueprintFile, outputFormat);
            LOGGER.debug("AST file: {}", result.getAst().getAbsolutePath());
            return result;

        } catch (Exception e) {
            throw new ParserException("Error parsing blueprint file to AST file: " + blueprintFile, e);
        }
    }
View Full Code Here


            FileUtils.deleteQuietly(result.getAst());

            return new ParsingResult<String>(result.getResult(), ast);

        } catch (IOException e) {
            throw new ParserException("Error converting blueprint file to string: " + blueprintFile, e);
        }
    }
View Full Code Here

            LOGGER.trace("AST stream opened");

            return new ParsingResult<InputStream>(result.getResult(), ast);

        } catch (IOException e) {
            throw new ParserException("Error converting blueprint file to stream: " + blueprintFile, e);
        }
    }
View Full Code Here

        result.setResult(parserResult);
        LOGGER.debug("Parser result: {}", parserResult);

        // check exit code
        if (0 != exitCode) {
            throw new ParserException("Parser returned with a non zero exit code: " + exitCode);
        }

        // check AST created
        if (astFile.exists()) {
            LOGGER.debug("AST file sized {} bytes created at: {}", astFile.length(), astFile.getAbsolutePath());
        } else {
            throw new ParserException("AST file not created at: " + astFile.getAbsolutePath());
        }

        result.setAst(astFile);
        return result;
    }
View Full Code Here

            LOGGER.info("Parsing {} format AST from stream", inputFormat);
            return yaml.loadAs(new InputStreamReader(astStream), getTargetModelClass());

        } catch (Exception e) {
            throw new ParserException(String.format("Error parsing %s format AST from stream", inputFormat), e);

        } finally {
            IOUtils.closeQuietly(astStream);
        }
    }
View Full Code Here

            LOGGER.info("Parsing {} format AST from stream", inputFormat);
            return gson.fromJson(new InputStreamReader(astStream), getTargetModelClass());

        } catch (Exception e) {
            throw new ParserException(String.format("Error parsing %s format AST from stream", inputFormat), e);

        } finally {
            IOUtils.closeQuietly(astStream);
        }
    }
View Full Code Here

        LOGGER.info("Parsing {} format AST file {}", inputFormat, astFile);

        try {
            return fromAst(FileUtils.openInputStream(astFile), inputFormat);
        } catch (IOException e) {
            throw new ParserException(String.format("Error parsing %s format AST file: %s", inputFormat, astFile), e);
        }
    }
View Full Code Here

            final int resultCode;
            final String strResultCode = matcher.group(1);
            if (StringUtils.isNumeric(strResultCode)) {
                resultCode = Integer.parseInt(strResultCode);
            } else {
                throw new ParserException(String.format("Result code '%s' was not numeric!", strResultCode));
            }

            /*
             * Extract the message and build SourceAnnotation.
             */
 
View Full Code Here

        }

        try {
            return fromAst(IOUtils.toInputStream(ast), inputFormat);
        } catch (Exception e) {
            throw new ParserException(String.format("Error parsing %s format AST string", inputFormat), e);
        }
    }
View Full Code Here

TOP

Related Classes of com.gatehill.apib.parser.exception.ParserException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.