Skip to content

Commit

Permalink
Modified ExceptionsHelper.unwrapCause handling for Exception
Browse files Browse the repository at this point in the history
Signed-off-by: aggarwalShivani <shivani.aggarwal@nokia.com>
  • Loading branch information
aggarwalShivani committed Jan 23, 2024
1 parent 4320a53 commit 7a63a9d
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ class TransportGetSMPoliciesAction @Inject constructor(
return try {
val searchResponse = client.suspendUntil { search(searchRequest, it) }
parseGetAllPoliciesResponse(searchResponse)
} catch (e: IndexNotFoundException) {
// config index hasn't been initialized, catch this here and show empty result for policies
Pair(emptyList(), 0L)
} catch (e: Exception) {
throw ExceptionsHelper.unwrapCause(e) as Exception
val unwrappedException = ExceptionsHelper.unwrapCause(e) as Exception

Check warning on line 77 in src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/get/TransportGetSMPoliciesAction.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/get/TransportGetSMPoliciesAction.kt#L76-L77

Added lines #L76 - L77 were not covered by tests
if (unwrappedException is IndexNotFoundException) {
// config index hasn't been initialized, catch this here and show empty result for policies
Pair(emptyList(), 0L)

Check warning on line 80 in src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/get/TransportGetSMPoliciesAction.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/api/transport/get/TransportGetSMPoliciesAction.kt#L80

Added line #L80 was not covered by tests
} else {
throw unwrappedException
}
}
}

Expand Down

0 comments on commit 7a63a9d

Please sign in to comment.