@@ -462,23 +462,25 @@ private <T> Optional<T> getResult(ISourceHandleSupplier<T> dataSupplier) throws
462462 private void dealWithException (Throwable t ) throws IoTDBException {
463463 t = getRootCause (t );
464464 stateMachine .transitionToFailed (t );
465- if ( stateMachine .getFailureStatus () != null ) {
466- throw new IoTDBException (
467- stateMachine . getFailureStatus () .getMessage (), stateMachine . getFailureStatus () .code );
468- } else if ( stateMachine . getFailureException () != null ) {
465+ TSStatus status = stateMachine .getFailureStatus ();
466+ if ( status != null ) {
467+ throw new IoTDBException ( status .getMessage (), status .code );
468+ } else {
469469 Throwable rootCause = stateMachine .getFailureException ();
470- if (rootCause instanceof IoTDBRuntimeException ) {
471- throw (IoTDBRuntimeException ) rootCause ;
472- } else if (rootCause instanceof IoTDBException ) {
473- throw (IoTDBException ) rootCause ;
474- } else if (rootCause instanceof DateTimeParseException ) {
475- throw new IoTDBRuntimeException (
476- rootCause .getMessage (), DATE_OUT_OF_RANGE .getStatusCode (), true );
470+ if (rootCause != null ) {
471+ if (rootCause instanceof IoTDBRuntimeException ) {
472+ throw (IoTDBRuntimeException ) rootCause ;
473+ } else if (rootCause instanceof IoTDBException ) {
474+ throw (IoTDBException ) rootCause ;
475+ } else if (rootCause instanceof DateTimeParseException ) {
476+ throw new IoTDBRuntimeException (
477+ rootCause .getMessage (), DATE_OUT_OF_RANGE .getStatusCode (), true );
478+ }
479+ throw new IoTDBException (rootCause , TSStatusCode .EXECUTE_STATEMENT_ERROR .getStatusCode ());
480+ } else {
481+ throwIfUnchecked (t );
482+ throw new IoTDBException (t , TSStatusCode .QUERY_PROCESS_ERROR .getStatusCode ());
477483 }
478- throw new IoTDBException (rootCause , TSStatusCode .EXECUTE_STATEMENT_ERROR .getStatusCode ());
479- } else {
480- throwIfUnchecked (t );
481- throw new IoTDBException (t , TSStatusCode .QUERY_PROCESS_ERROR .getStatusCode ());
482484 }
483485 }
484486
0 commit comments