public static MySQLErrPacket newInstance ( final int sequenceId , final Exception cause ) { if ( cause instanceof SQLException ) { SQLException sqlException = ( SQLException ) cause ; return new MySQLErrPacket ( sequenceId , sqlException . getErrorCode ( ) , sqlException . getSQLState ( ) , sqlException . getMessage ( ) ) ; } if ( cause instanceof ShardingCTLException ) { ShardingCTLException shardingCTLException = ( ShardingCTLException ) cause ; return new MySQLErrPacket ( sequenceId , ShardingCTLErrorCode . valueOf ( shardingCTLException ) , shardingCTLException . getShardingCTL ( ) ) ; } if ( cause instanceof TableModifyInTransactionException ) { return new MySQLErrPacket ( sequenceId , MySQLServerErrorCode . ER_ERROR_ON_MODIFYING_GTID_EXECUTED_TABLE , ( ( TableModifyInTransactionException ) cause ) . getTableName ( ) ) ; } if ( cause instanceof UnknownDatabaseException ) { return new MySQLErrPacket ( sequenceId , MySQLServerErrorCode . ER_BAD_DB_ERROR , ( ( UnknownDatabaseException ) cause ) . getDatabaseName ( ) ) ; } if ( cause instanceof NoDatabaseSelectedException ) { return new MySQLErrPacket ( sequenceId , MySQLServerErrorCode . ER_NO_DB_ERROR ) ; } return new MySQLErrPacket ( sequenceId , CommonErrorCode . UNKNOWN_EXCEPTION , cause . getMessage ( ) ) ; }
New instance of MytSQL ERR packet .