diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryApplicationsImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryApplicationsImpl.java index caa5795483121..65bbac0e1e592 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryApplicationsImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryApplicationsImpl.java @@ -8,7 +8,6 @@ import com.azure.resourcemanager.authorization.AuthorizationManager; import com.azure.resourcemanager.authorization.models.ActiveDirectoryApplication; import com.azure.resourcemanager.authorization.models.ActiveDirectoryApplications; -import com.azure.resourcemanager.authorization.models.GraphErrorException; import com.azure.resourcemanager.authorization.fluent.inner.ApplicationInner; import com.azure.resourcemanager.authorization.fluent.ApplicationsClient; import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.CreatableResourcesImpl; @@ -72,7 +71,6 @@ public ActiveDirectoryApplicationImpl getById(String id) { public Mono getByIdAsync(String id) { return innerCollection .getAsync(id) - .onErrorResume(GraphErrorException.class, e -> Mono.empty()) .flatMap( applicationInner -> new ActiveDirectoryApplicationImpl(applicationInner, manager()).refreshCredentialsAsync()); @@ -93,10 +91,13 @@ public Mono getByNameAsync(String name) { Mono .defer( () -> { - UUID.fromString(trimmed); - return inner().listAsync(String.format("appId eq '%s'", trimmed)).singleOrEmpty(); + try { + UUID.fromString(trimmed); + return inner().listAsync(String.format("appId eq '%s'", trimmed)).singleOrEmpty(); + } catch (IllegalArgumentException e) { + return Mono.empty(); + } })) - .onErrorResume(IllegalArgumentException.class, e -> Mono.empty()) .map(applicationInner -> new ActiveDirectoryApplicationImpl(applicationInner, manager())) .flatMap(activeDirectoryApplication -> activeDirectoryApplication.refreshCredentialsAsync()); } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryGroupsImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryGroupsImpl.java index 846b318c71686..47e3a21789047 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryGroupsImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryGroupsImpl.java @@ -8,7 +8,6 @@ import com.azure.resourcemanager.authorization.AuthorizationManager; import com.azure.resourcemanager.authorization.models.ActiveDirectoryGroup; import com.azure.resourcemanager.authorization.models.ActiveDirectoryGroups; -import com.azure.resourcemanager.authorization.models.GraphErrorException; import com.azure.resourcemanager.authorization.fluent.inner.ADGroupInner; import com.azure.resourcemanager.authorization.fluent.GroupsClient; import com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.CreatableWrappersImpl; @@ -48,7 +47,6 @@ public Mono getByIdAsync(String id) { .inner() .getGroups() .getAsync(id) - .onErrorResume(GraphErrorException.class, e -> Mono.empty()) .map(groupInner -> new ActiveDirectoryGroupImpl(groupInner, manager())); } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryUsersImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryUsersImpl.java index a917e23f06bee..ea77ec3226c62 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryUsersImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ActiveDirectoryUsersImpl.java @@ -49,7 +49,6 @@ public Mono getByIdAsync(String id) { .inner() .getUsers() .getAsync(id) - .onErrorResume(GraphErrorException.class, e -> Mono.empty()) .map(userInner -> new ActiveDirectoryUserImpl(userInner, manager())); } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentHelper.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentHelper.java index 5658bad032fce..d1890d45ac4bb 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentHelper.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentHelper.java @@ -96,7 +96,6 @@ public RoleAssignmentHelper withAccessTo(final String scope, final BuiltInRole a .createAsync() .last() .onErrorResume( - (Function>) throwable -> { if (isRoleAssignmentExists(throwable)) { return cxt.voidMono(); @@ -150,7 +149,6 @@ public RoleAssignmentHelper withAccessTo(final String scope, final String roleDe .createAsync() .last() .onErrorResume( - (Function>) throwable -> { if (isRoleAssignmentExists(throwable)) { return cxt.voidMono(); diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentsImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentsImpl.java index d7c6ac9e4e476..185f2128a8be5 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentsImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleAssignmentsImpl.java @@ -5,7 +5,6 @@ import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.exception.ManagementException; import com.azure.resourcemanager.authorization.AuthorizationManager; import com.azure.resourcemanager.authorization.models.RoleAssignment; import com.azure.resourcemanager.authorization.models.RoleAssignments; @@ -41,7 +40,6 @@ public RoleAssignmentImpl getById(String objectId) { public Mono getByIdAsync(String id) { return inner() .getByIdAsync(id) - .onErrorResume(ManagementException.class, e -> Mono.empty()) .map( roleAssignmentInner -> new RoleAssignmentImpl(roleAssignmentInner.name(), roleAssignmentInner, manager())); @@ -66,7 +64,6 @@ public PagedIterable listByScope(String scope) { public Mono getByScopeAsync(String scope, String name) { return inner() .getAsync(scope, name) - .onErrorResume(ManagementException.class, e -> Mono.empty()) .map( roleAssignmentInner -> new RoleAssignmentImpl(roleAssignmentInner.name(), roleAssignmentInner, manager())); @@ -81,7 +78,6 @@ protected RoleAssignmentImpl wrapModel(String name) { public Mono deleteByIdAsync(String id) { return inner() .deleteByIdAsync(id) - .onErrorResume(ManagementException.class, e -> Mono.empty()) .map( roleAssignmentInner -> new RoleAssignmentImpl(roleAssignmentInner.name(), roleAssignmentInner, manager())); diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleDefinitionsImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleDefinitionsImpl.java index 03a5d6eb7e5c9..36cdcc223dd71 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleDefinitionsImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/RoleDefinitionsImpl.java @@ -5,7 +5,6 @@ import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedIterable; -import com.azure.core.management.exception.ManagementException; import com.azure.resourcemanager.authorization.AuthorizationManager; import com.azure.resourcemanager.authorization.models.RoleDefinition; import com.azure.resourcemanager.authorization.models.RoleDefinitions; @@ -41,7 +40,6 @@ public RoleDefinition getById(String objectId) { public Mono getByIdAsync(String id) { return inner() .getByIdAsync(id) - .onErrorResume(ManagementException.class, e -> Mono.empty()) .map(roleDefinitionInner -> new RoleDefinitionImpl(roleDefinitionInner, manager())); } @@ -54,7 +52,6 @@ public RoleDefinition getByScope(String scope, String name) { public Mono getByScopeAsync(String scope, String name) { return inner() .getAsync(scope, name) - .onErrorResume(ManagementException.class, e -> Mono.empty()) .map(roleDefinitionInner -> new RoleDefinitionImpl(roleDefinitionInner, manager())); } @@ -79,7 +76,6 @@ public PagedIterable listByScope(String scope) { public Mono getByScopeAndRoleNameAsync(String scope, String roleName) { return inner() .listAsync(scope, String.format("roleName eq '%s'", roleName)) - .onErrorResume(ManagementException.class, e -> Mono.empty()) .singleOrEmpty() .map(roleDefinitionInner -> new RoleDefinitionImpl(roleDefinitionInner, manager())); } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ServicePrincipalsImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ServicePrincipalsImpl.java index 6b4bb18730045..eca51340fc1bc 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ServicePrincipalsImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/resourcemanager/authorization/implementation/ServicePrincipalsImpl.java @@ -6,7 +6,6 @@ import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedIterable; import com.azure.resourcemanager.authorization.AuthorizationManager; -import com.azure.resourcemanager.authorization.models.GraphErrorException; import com.azure.resourcemanager.authorization.models.ServicePrincipal; import com.azure.resourcemanager.authorization.models.ServicePrincipals; import com.azure.resourcemanager.authorization.fluent.inner.ServicePrincipalInner; @@ -69,7 +68,6 @@ public ServicePrincipalImpl getById(String id) { public Mono getByIdAsync(String id) { return innerCollection .getAsync(id) - .onErrorResume(GraphErrorException.class, e -> Mono.empty()) .flatMap( servicePrincipalInner -> new ServicePrincipalImpl(servicePrincipalInner, manager()).refreshCredentialsAsync()); diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/DiskImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/DiskImpl.java index ead47902ac27c..304fb276c0540 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/DiskImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/DiskImpl.java @@ -106,7 +106,6 @@ public Mono grantAccessAsync(int accessDurationInSeconds) { .inner() .getDisks() .grantAccessAsync(this.resourceGroupName(), this.name(), grantAccessDataInner) - .onErrorResume(e -> Mono.empty()) .map(accessUriInner -> accessUriInner.accessSas()); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImageVersionsImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImageVersionsImpl.java index de260341acbea..e7135d7f7c417 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImageVersionsImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImageVersionsImpl.java @@ -58,7 +58,6 @@ public Mono getByGalleryImageAsync( String resourceGroupName, String galleryName, String galleryImageName, String galleryImageVersionName) { return inner() .getAsync(resourceGroupName, galleryName, galleryImageName, galleryImageVersionName) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImagesImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImagesImpl.java index c99d8b8918eff..557d090cea230 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImagesImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/GalleryImagesImpl.java @@ -53,7 +53,6 @@ public PagedIterable listByGallery(String resourceGroupName, Strin public Mono getByGalleryAsync(String resourceGroupName, String galleryName, String galleryImageName) { return inner() .getAsync(resourceGroupName, galleryName, galleryImageName) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java index 8953db53da623..9e0ea3349cacb 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java @@ -117,8 +117,7 @@ private Mono retrieveExtensionWithInstanceViewAsyn return computeManager .inner() .getVirtualMachineExtensions() - .getAsync(rgName, vmName, extension.name(), "instanceView") - .onErrorResume(e -> Mono.empty()); + .getAsync(rgName, vmName, extension.name(), "instanceView"); } /** @@ -133,12 +132,7 @@ private Mono retrieveEncryptExtensionWithInstanceV .inner() .getVirtualMachines() .getByResourceGroupAsync(rgName, vmName) - .onErrorResume( - e -> - Mono - .error( - new Exception( - String.format("VM with name '%s' not found (resource group '%s')", vmName, rgName)))) + // Exception if vm not found .flatMap( virtualMachine -> { if (virtualMachine.resources() != null) { diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeNoAADEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeNoAADEncryptionMonitorImpl.java index edd531cec7f71..2d0f60d336312 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeNoAADEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/LinuxDiskVolumeNoAADEncryptionMonitorImpl.java @@ -128,13 +128,8 @@ private Mono retrieveVirtualMachineAsync() { return computeManager .inner() .getVirtualMachines() - .getByResourceGroupAsync(rgName, vmName) - .onErrorResume( - e -> - Mono - .error( - new Exception( - String.format("VM with name '%s' not found (resource group '%s')", vmName, rgName)))); + .getByResourceGroupAsync(rgName, vmName); + // Exception if vm not found } private boolean hasEncryptionExtensionInstanceView() { diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/ProxyEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/ProxyEncryptionMonitorImpl.java index c47503bbdbcd7..0f7d30dd07c65 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/ProxyEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/ProxyEncryptionMonitorImpl.java @@ -113,8 +113,8 @@ private Mono retrieveVirtualMachineAsync() { return computeManager .inner() .getVirtualMachines() - .getByResourceGroupAsync(ResourceUtils.groupFromResourceId(vmId), ResourceUtils.nameFromResourceId(vmId)) - .onErrorResume(e -> Mono.error(new Exception(String.format("VM with id '%s' not found.", vmId)))); + .getByResourceGroupAsync(ResourceUtils.groupFromResourceId(vmId), ResourceUtils.nameFromResourceId(vmId)); + // Exception if vm not found } /** diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotImpl.java index 71bd42f54de82..69f114fa68a45 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotImpl.java @@ -93,7 +93,6 @@ public Mono grantAccessAsync(int accessDurationInSeconds) { .inner() .getSnapshots() .grantAccessAsync(resourceGroupName(), name(), grantAccessDataInner) - .onErrorResume(e -> Mono.empty()) .map(accessUriInner -> accessUriInner.accessSas()); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotsImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotsImpl.java index 55fdeb60df339..1f15fcb331bfa 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotsImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/SnapshotsImpl.java @@ -29,7 +29,6 @@ public Mono grantAccessAsync( grantAccessDataInner.withAccess(accessLevel).withDurationInSeconds(accessDuration); return inner() .grantAccessAsync(resourceGroupName, snapshotName, grantAccessDataInner) - .onErrorResume(e -> Mono.empty()) .map(accessUriInner -> accessUriInner.accessSas()); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImageVersionImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImageVersionImpl.java index 3017cbcbf3eea..ff5a66fe34de2 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImageVersionImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImageVersionImpl.java @@ -60,7 +60,6 @@ public Mono getImageAsync() { final VirtualMachineExtensionImageVersionImpl self = this; return client .getAsync(regionName(), type().publisher().name(), type().name(), name()) - .onErrorResume(e -> Mono.empty()) .map(inner -> new VirtualMachineExtensionImageImpl(self, inner)); } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImagesImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImagesImpl.java index 455645b2f2753..3facbf7e77ec4 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImagesImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImagesImpl.java @@ -4,13 +4,14 @@ import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.exception.ManagementException; import com.azure.resourcemanager.compute.models.VirtualMachineExtensionImage; import com.azure.resourcemanager.compute.models.VirtualMachineExtensionImageVersion; import com.azure.resourcemanager.compute.models.VirtualMachineExtensionImages; import com.azure.resourcemanager.compute.models.VirtualMachinePublishers; import com.azure.resourcemanager.resources.fluentcore.arm.Region; import com.azure.resourcemanager.resources.fluentcore.utils.PagedConverter; -import reactor.core.publisher.Mono; +import reactor.core.publisher.Flux; /** The implementation for {@link VirtualMachineExtensionImages}. */ public class VirtualMachineExtensionImagesImpl implements VirtualMachineExtensionImages { @@ -44,9 +45,10 @@ public PagedFlux listByRegionAsync(String regionNa virtualMachinePublisher .extensionTypes() .listAsync() - .onErrorResume(e -> Mono.empty()) - .flatMap( - virtualMachineExtensionImageType -> virtualMachineExtensionImageType.versions().listAsync()) + .onErrorResume(ManagementException.class, + e -> e.getResponse().getStatusCode() == 404 ? Flux.empty() : Flux.error(e)) + .flatMap(virtualMachineExtensionImageType -> + virtualMachineExtensionImageType.versions().listAsync()) .flatMap(VirtualMachineExtensionImageVersion::getImageAsync)); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImpl.java index 039b8d9cb224f..a2b170625b66e 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineExtensionImpl.java @@ -92,7 +92,6 @@ public Mono getInstanceViewAsync() { return this .client .getAsync(this.parent().resourceGroupName(), this.parent().name(), this.name(), "instanceView") - .onErrorResume(e -> Mono.empty()) .map(inner -> inner.instanceView()); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineImagesImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineImagesImpl.java index b2529d1d4b7fd..0fc380749ed39 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineImagesImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/VirtualMachineImagesImpl.java @@ -4,6 +4,7 @@ import com.azure.core.http.rest.PagedFlux; import com.azure.core.http.rest.PagedIterable; +import com.azure.core.management.exception.ManagementException; import com.azure.resourcemanager.compute.models.VirtualMachineImage; import com.azure.resourcemanager.compute.models.VirtualMachineImages; import com.azure.resourcemanager.compute.models.VirtualMachinePublishers; @@ -12,8 +13,9 @@ import com.azure.resourcemanager.compute.fluent.VirtualMachineImagesClient; import com.azure.resourcemanager.resources.fluentcore.arm.Region; import com.azure.resourcemanager.resources.fluentcore.utils.PagedConverter; +import reactor.core.publisher.Flux; + import java.util.List; -import reactor.core.publisher.Mono; /** The implementation for {@link VirtualMachineImages}. */ public class VirtualMachineImagesImpl implements VirtualMachineImages { @@ -85,7 +87,8 @@ public PagedFlux listByRegionAsync(String regionName) { virtualMachinePublisher .offers() .listAsync() - .onErrorResume(e -> Mono.empty()) + .onErrorResume(ManagementException.class, + e -> e.getResponse().getStatusCode() == 404 ? Flux.empty() : Flux.error(e)) .flatMap(virtualMachineOffer -> virtualMachineOffer.skus().listAsync()) .flatMap(virtualMachineSku -> virtualMachineSku.images().listAsync())); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeLegacyEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeLegacyEncryptionMonitorImpl.java index b9c284ea3fd2f..f8e78ecbafa8d 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeLegacyEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeLegacyEncryptionMonitorImpl.java @@ -152,13 +152,8 @@ private Mono retrieveVirtualMachineAsync() { .computeManager .inner() .getVirtualMachines() - .getByResourceGroupAsync(rgName, vmName) - .onErrorResume( - e -> - Mono - .error( - new Exception( - String.format("VM with name '%s' not found (resource group '%s')", vmName, rgName)))); + .getByResourceGroupAsync(rgName, vmName); + // Exception if vm not found } private boolean hasEncryptionDetails() { diff --git a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeNoAADEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeNoAADEncryptionMonitorImpl.java index 35e00710e92a7..a00c24daaa3a3 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeNoAADEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/resourcemanager/compute/implementation/WindowsVolumeNoAADEncryptionMonitorImpl.java @@ -155,13 +155,8 @@ private Mono retrieveVirtualMachineAsync() { .computeManager .inner() .getVirtualMachines() - .getByResourceGroupAsync(rgName, vmName) - .onErrorResume( - e -> - Mono - .error( - new Exception( - String.format("VM with name '%s' not found (resource group '%s')", vmName, rgName)))); + .getByResourceGroupAsync(rgName, vmName); + // Exception if vm not found } /** diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/ARecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/ARecordSetsImpl.java index 9efe4d3e109b3..4049e448105a0 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/ARecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/ARecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/AaaaRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/AaaaRecordSetsImpl.java index 0cb2487772676..13de8476a6d6d 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/AaaaRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/AaaaRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CNameRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CNameRecordSetsImpl.java index f03e366188f38..8904b8ed5e6eb 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CNameRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CNameRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CaaRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CaaRecordSetsImpl.java index c6157540e12eb..723c7a699d79f 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CaaRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/CaaRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/MXRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/MXRecordSetsImpl.java index 33ac1dfac9ed4..f3b00f1a3f776 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/MXRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/MXRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/NSRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/NSRecordSetsImpl.java index 8aa272302e192..f1dd2356eabc6 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/NSRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/NSRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/PtrRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/PtrRecordSetsImpl.java index 730ae1438ddc4..118e6118a4325 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/PtrRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/PtrRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/SrvRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/SrvRecordSetsImpl.java index 7a7eb3a0629b5..02fc4275e5c86 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/SrvRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/SrvRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/TxtRecordSetsImpl.java b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/TxtRecordSetsImpl.java index 70399b7f49499..8ea6f6e87d058 100644 --- a/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/TxtRecordSetsImpl.java +++ b/sdk/dns/mgmt/src/main/java/com/azure/resourcemanager/dns/implementation/TxtRecordSetsImpl.java @@ -30,7 +30,6 @@ public Mono getByNameAsync(String name) { .inner() .getRecordSets() .getAsync(this.dnsZone.resourceGroupName(), this.dnsZone.name(), name, this.recordType) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyAssignmentsImpl.java b/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyAssignmentsImpl.java index fe9c883d19582..2cf01f800fc8b 100644 --- a/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyAssignmentsImpl.java +++ b/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyAssignmentsImpl.java @@ -80,7 +80,6 @@ public PolicyAssignment getById(String id) { @Override public Mono getByIdAsync(String id) { return client.getByIdAsync(id) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); } diff --git a/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyDefinitionsImpl.java b/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyDefinitionsImpl.java index 3b63e50176eba..b0504c94105c3 100644 --- a/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyDefinitionsImpl.java +++ b/sdk/resources/mgmt/src/main/java/com/azure/resourcemanager/resources/implementation/PolicyDefinitionsImpl.java @@ -44,7 +44,6 @@ public PolicyDefinition getByName(String name) { @Override public Mono getByNameAsync(String name) { return client.getAsync(name) - .onErrorResume(e -> Mono.empty()) .map(this::wrapModel); }