How to display an error message based on exception thrown in server side onto the client side

2020-05-18 java hsqldb
**create user admin identified by :pass123**

public final Create_user_stmtContext create_user_stmt() throws RecognitionException {
        Create_user_stmtContext _localctx = new Create_user_stmtContext(_ctx, getState());
        enterRule(_localctx, 10, RULE_create_user_stmt);
        try {
            enterOuterAlt(_localctx, 1);
            {
            setState(145);
            match(K_CREATE);
            setState(146);
            match(K_USER);
            setState(147);
            user_name();
            setState(148);
            match(K_IDENTIFIED);
            setState(149);
            match(K_BY);
            setState(150);
            password();
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            _errHandler.reportError(this, re);
            _errHandler.recover(this, re);
        }
        finally {
            exitRule();
        }
        return _localctx;
    }
________________________________________________________________________________________________________
**Error shown in server side**

[Thread-0] ERROR org.apache.thrift.ProcessFunction - Internal error processing executeStatement
org.antlr.v4.runtime.misc.ParseCancellationException: line 1:32 mismatched input 'pass123' expecting STRING_LITERAL

    at cn.edu.thssdb.parser.ThrowingErrorListener.syntaxError(ThrowingErrorListener.java:13)
    at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
    at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
    at org.antlr.v4.runtime.DefaultErrorStrategy.reportInputMismatch(DefaultErrorStrategy.java:327)
    at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:139)
    at cn.edu.thssdb.parser.SQLParser.password(SQLParser.java:3205)
    at cn.edu.thssdb.parser.SQLParser.create_user_stmt(SQLParser.java:679)
    at cn.edu.thssdb.parser.SQLParser.sql_stmt(SQLParser.java:387)
    at cn.edu.thssdb.service.IServiceHandler.executeStatement(IServiceHandler.java:65)
    at cn.edu.thssdb.rpc.thrift.IService$Processor$executeStatement.getResult(IService.java:410)
    at cn.edu.thssdb.rpc.thrift.IService$Processor$executeStatement.getResult(IService.java:390)
    at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:38)
    at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:38)
    at org.apache.thrift.server.TSimpleServer.serve(TSimpleServer.java:80)
    at cn.edu.thssdb.server.ThssDB.setUp(ThssDB.java:60)
    at cn.edu.thssdb.server.ThssDB.lambda$start$0(ThssDB.java:51)
    at java.lang.Thread.run(Thread.java:748)

I would like to display a message like "Invalid password input!" in the client side but how do I throw an exception message in client side based on the exception caught in the server side which is the expecting STRING_LITERAL in this case.

Answers

Related