You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/06/26 04:17:20 UTC

[GitHub] [shardingsphere] ninjaboy97 commented on a diff in pull request #18598: Print error SQL when throwing exception.SQLParsingException

ninjaboy97 commented on code in PR #18598:
URL: https://github.com/apache/shardingsphere/pull/18598#discussion_r906753000


##########
shardingsphere-distsql/shardingsphere-distsql-parser/src/main/java/org/apache/shardingsphere/distsql/parser/core/advanced/AdvancedDistSQLStatementParserEngine.java:
##########
@@ -40,12 +40,14 @@ public SQLStatement parse(final String sql) {
         ASTNode astNode = parseToASTNode(sql);
         return getSQLStatement(sql, (ParseASTNode) astNode);
     }
-    
+
     private ASTNode parseToASTNode(final String sql) {
         try {
             return SQLParserFactory.newInstance(sql, AdvancedDistSQLLexer.class, AdvancedDistSQLParser.class).parse();
-        } catch (final ParseCancellationException | SQLParsingException ignored) {
-            throw new SQLParsingException("You have an error in your SQL syntax.");
+        } catch (final ParseCancellationException ignored) {
+            throw new SQLParsingException("You have an error in your SQL syntax: " + sql);
+        } catch (final SQLParsingException sqlParsingException) {
+            throw sqlParsingException;

Review Comment:
   The ParseCancellationException does not include SQL and parse error cause.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org