private QueryParserException convertParserException(ParseException pe) { if (pe.currentToken == null) { List<Token> preceeding = findPreceeding(parser.token, 1); if (!preceeding.isEmpty()) { pe.currentToken = preceeding.get(0); } else { pe.currentToken = parser.token; } } QueryParserException qpe = new QueryParserException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31100, getMessage(pe, 10))); qpe.setParseException(pe); return qpe; }
public Command parseCommand(final String sql, ParseInfo parseInfo, boolean designerCommands, String vdbName, String vdbVersion, String schemaName, CommandContext commandContext) throws QueryParserException { if(sql == null || sql.length() == 0) { throw new QueryParserException(QueryPlugin.Event.TEIID30377, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30377)); } Command result = null; try{ if (designerCommands) { result = getSqlParser(sql).designerCommand(parseInfo); } else { result = getSqlParser(sql).command(parseInfo); } result.setCacheHint(SQLParserUtil.getQueryCacheOption(sql)); } catch(ParseException pe) { if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) { throw new QueryParserException(QueryPlugin.Event.TEIID30378, convertParserException(pe), QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30378, sql)); } throw convertParserException(pe); } finally { tm.reinit(); } return result; }
@Test public void testExceptionMessageWithLocation() { try { QueryParser.getQueryParser().parseCommand("SELECT FROM"); //$NON-NLS-1$ } catch(QueryParserException e) { assertTrue(e.getMessage(), e.getMessage().startsWith("TEIID31100 Parsing error: Encountered \"SELECT [*]FROM[*]\" at line 1, column 8.")); //$NON-NLS-1$ } }
public Command parseCommand(final String sql, ParseInfo parseInfo, boolean designerCommands, String vdbName, String vdbVersion, String schemaName, CommandContext commandContext) throws QueryParserException { if(sql == null || sql.length() == 0) { throw new QueryParserException(QueryPlugin.Event.TEIID30377, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30377)); } Command result = null; try{ if (designerCommands) { result = getSqlParser(sql).designerCommand(parseInfo); } else { result = getSqlParser(sql).command(parseInfo); } result.setCacheHint(SQLParserUtil.getQueryCacheOption(sql)); } catch(ParseException pe) { if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) { throw new QueryParserException(QueryPlugin.Event.TEIID30378, convertParserException(pe), QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30378, sql)); } throw convertParserException(pe); } finally { tm.reinit(); } return result; }
private QueryParserException convertParserException(ParseException pe) { if (pe.currentToken == null) { List<Token> preceeding = findPreceeding(parser.token, 1); if (!preceeding.isEmpty()) { pe.currentToken = preceeding.get(0); } else { pe.currentToken = parser.token; } } QueryParserException qpe = new QueryParserException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31100, getMessage(pe, 10))); qpe.setParseException(pe); return qpe; }
public Command parseCommand(final String sql, ParseInfo parseInfo, boolean designerCommands, String vdbName, String vdbVersion, String schemaName, CommandContext commandContext) throws QueryParserException { if(sql == null || sql.length() == 0) { throw new QueryParserException(QueryPlugin.Event.TEIID30377, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30377)); } Command result = null; try{ if (designerCommands) { result = getSqlParser(sql).designerCommand(parseInfo); } else { result = getSqlParser(sql).command(parseInfo); } result.setCacheHint(SQLParserUtil.getQueryCacheOption(sql)); } catch(ParseException pe) { if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) { throw new QueryParserException(QueryPlugin.Event.TEIID30378, convertParserException(pe), QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30378, sql)); } throw convertParserException(pe); } finally { tm.reinit(); } return result; }
private QueryParserException convertParserException(ParseException pe) { if (pe.currentToken == null) { List<Token> preceeding = findPreceeding(parser.token, 1); if (!preceeding.isEmpty()) { pe.currentToken = preceeding.get(0); } else { pe.currentToken = parser.token; } } QueryParserException qpe = new QueryParserException(QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31100, getMessage(pe, 10))); qpe.setParseException(pe); return qpe; }