throw (RecognitionException)e.getCause();
/** * Parse a string into either a full PSL Rule or a rule without weight or potential squaring information. */ public static RulePartial loadRulePartial(DataStore data, String input) throws IOException { PSLParser parser = getParser(input); PslRulePartialContext context = null; try { context = parser.pslRulePartial(); } catch (ParseCancellationException ex) { // Cancel the parse and rethrow the cause. throw (RuntimeException)ex.getCause(); } ModelLoader visitor = new ModelLoader(data); return visitor.visitPslRulePartial(context); }
if (x.getCause() instanceof InputMismatchException) { InputMismatchException xx = (InputMismatchException)x.getCause(); String offend = xx.getOffendingToken().getText(); throw new OrcaException(x, "Invalid SQL. Offending token: {}", offend); if (x.getCause() instanceof NoViableAltException) { NoViableAltException xx = (NoViableAltException)x.getCause(); String offend = xx.getOffendingToken().getText(); throw new OrcaException(x, "Invalid SQL. Offending token: {}", offend);
/** * Parse and return a Model (collection of rules). * The input should only contain rules and the DataStore should contain all the predicates * used by the rules. */ public static Model load(DataStore data, Reader input) throws IOException { PSLParser parser = getParser(input); ProgramContext program = null; try { program = parser.program(); } catch (ParseCancellationException ex) { // Cancel the parse and rethrow the cause. throw (RuntimeException)ex.getCause(); } ModelLoader visitor = new ModelLoader(data); return visitor.visitProgram(program, parser); }
public <T extends ExecutionResult> T execute() { assertNotNull(arguments, "Arguments can't be null"); LOGGER.info("Executing request. Operation name: {}. Request: {} ", operationName, requestQuery); Parser parser = new Parser(); Document document; try { document = parser.parseDocument(requestQuery); } catch (ParseCancellationException e) { RecognitionException recognitionException = (RecognitionException) e.getCause(); SourceLocation sourceLocation = new SourceLocation(recognitionException.getOffendingToken().getLine(), recognitionException.getOffendingToken().getCharPositionInLine()); InvalidSyntaxError invalidSyntaxError = new InvalidSyntaxError(sourceLocation); return (T) new GraphQLRxExecutionResult(Observable.just(null), Observable.just(Arrays.asList(invalidSyntaxError))); } Validator validator = new Validator(); List<ValidationError> validationErrors = validator.validateDocument(graphQLSchemaHolder.getGraphQLSchema(), document); if (validationErrors.size() > 0) { return (T) new GraphQLRxExecutionResult(Observable.just(null), Observable.just(validationErrors)); } if (executionStrategy == null) { if (executorService == null) { executionStrategy = new GraphQLDefaultRxExecutionStrategy(graphQLSchemaHolder, maxQueryDepth, maxQueryComplexity); } else { executionStrategy = new GraphQLExecutorServiceRxExecutionStrategy(graphQLSchemaHolder, executorService, maxQueryDepth, maxQueryComplexity); } } RxExecution execution = new RxExecution(graphQLSchemaHolder, maxQueryDepth, maxQueryComplexity, executionStrategy); ExecutionResult executionResult = execution.execute(graphQLSchemaHolder.getGraphQLSchema(), context, document, operationName, arguments); return (T) (executionResult instanceof GraphQLRxExecutionResult ? executionResult : new GraphQLRxExecutionResult(Observable.just(executionResult.getData()), Observable.just(executionResult.getErrors()))); }
private static GlobNode parse(ANTLRInputStream input) throws GlobParseException { GlobLexer lexer = new GlobLexer(input); CommonTokenStream tokenStream = new CommonTokenStream(lexer); GlobParser parser = new GlobParser(tokenStream); parser.setErrorHandler(new BailErrorStrategy()); ParseTreeWalker walker = new ParseTreeWalker(); GlobListener listener = new GlobListener(); try { walker.walk(listener, parser.rootGlob()); } catch (ParseCancellationException e) { RecognitionException ex = ((RecognitionException) e.getCause()); throw new GlobParseException("Unable to parse glob: Error at token " + ex.getOffendingToken().getText() + " at position " + ex.getOffendingToken().getLine() + ":" + ex.getOffendingToken().getCharPositionInLine(), ex); } return listener.popNode(); }
Throwable cause = e.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause;
Throwable cause = pce.getCause(); if (cause instanceof RecognitionException) { RecognitionException re = (RecognitionException) cause;
throw (RecognitionException)e.getCause();
throw (RecognitionException)e.getCause();
throw (RecognitionException)e.getCause();
throw (RecognitionException)e.getCause();