@@ -13,7 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
13
13
import com .fasterxml .jackson .module .scala .DefaultScalaModule
14
14
import org .apache .commons .text .StringEscapeUtils .unescapeJava
15
15
import org .opensearch .flint .core .IRestHighLevelClient
16
- import org .opensearch .flint .core .logging .{CustomLogging , OperationMessage }
16
+ import org .opensearch .flint .core .logging .{CustomLogging , ExceptionMessages , OperationMessage }
17
17
import org .opensearch .flint .core .metrics .MetricConstants
18
18
import org .opensearch .flint .core .metrics .MetricsUtil .incrementCounter
19
19
import play .api .libs .json ._
@@ -454,34 +454,43 @@ trait FlintJobExecutor {
454
454
def processQueryException (ex : Exception ): String = {
455
455
getRootCause(ex) match {
456
456
case r : ParseException =>
457
- handleQueryException(r, " Syntax error " )
457
+ handleQueryException(r, ExceptionMessages . SyntaxErrorPrefix )
458
458
case r : AmazonS3Exception =>
459
459
incrementCounter(MetricConstants .S3_ERR_CNT_METRIC )
460
460
handleQueryException(
461
461
r,
462
- " Fail to read data from S3. Cause " ,
462
+ ExceptionMessages . S3ErrorPrefix ,
463
463
Some (r.getServiceName),
464
464
Some (r.getStatusCode))
465
465
case r : AWSGlueException =>
466
466
incrementCounter(MetricConstants .GLUE_ERR_CNT_METRIC )
467
467
// Redact Access denied in AWS Glue service
468
468
r match {
469
469
case accessDenied : AccessDeniedException =>
470
- accessDenied.setErrorMessage(
471
- " Access denied in AWS Glue service. Please check permissions." )
470
+ accessDenied.setErrorMessage(ExceptionMessages .GlueAccessDeniedMessage )
472
471
case _ => // No additional action for other types of AWSGlueException
473
472
}
474
473
handleQueryException(
475
474
r,
476
- " Fail to read data from Glue. Cause " ,
475
+ ExceptionMessages . GlueErrorPrefix ,
477
476
Some (r.getServiceName),
478
477
Some (r.getStatusCode))
479
478
case r : AnalysisException =>
480
- handleQueryException(r, " Fail to analyze query. Cause " )
479
+ handleQueryException(r, ExceptionMessages . QueryAnalysisErrorPrefix )
481
480
case r : SparkException =>
482
- handleQueryException(r, " Spark exception. Cause " )
481
+ handleQueryException(r, ExceptionMessages . SparkExceptionErrorPrefix )
483
482
case r : Exception =>
484
- handleQueryException(r, " Fail to run query. Cause" )
483
+ val rootCauseClassName = ex.getClass.getName
484
+ val errMsg = ex.getMessage
485
+ logDebug(s " Root cause class name: $rootCauseClassName" )
486
+ logDebug(s " Root cause error message: $errMsg" )
487
+ if (rootCauseClassName == " org.apache.hadoop.hive.metastore.api.MetaException" &&
488
+ errMsg.contains(" com.amazonaws.services.glue.model.AccessDeniedException" )) {
489
+ val e = new SecurityException (ExceptionMessages .GlueAccessDeniedMessage )
490
+ handleQueryException(e, ExceptionMessages .QueryRunErrorPrefix )
491
+ } else {
492
+ handleQueryException(ex, ExceptionMessages .QueryRunErrorPrefix )
493
+ }
485
494
}
486
495
}
487
496
0 commit comments