From: Anshul Gangwar <anshul.gang...@citrix.com>

Signed-off-by: Anshul Gangwar <anshul.gang...@citrix.com>
---
 server/src/com/cloud/user/DomainManagerImpl.java |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/server/src/com/cloud/user/DomainManagerImpl.java 
b/server/src/com/cloud/user/DomainManagerImpl.java
index 3223d8c..ea76bae 100644
--- a/server/src/com/cloud/user/DomainManagerImpl.java
+++ b/server/src/com/cloud/user/DomainManagerImpl.java
@@ -228,22 +228,18 @@ public class DomainManagerImpl implements DomainManager, 
DomainService, Manager
             long ownerId = domain.getAccountId();
             if ((cleanup != null) && cleanup.booleanValue()) {
                 if (!cleanupDomain(domain.getId(), ownerId)) {
-                    s_logger.error("Failed to clean up domain resources and 
sub domains, delete failed on domain " + domain.getName() + " (id: " + 
domain.getId() + ").");
-                    return false;
+                    throw new CloudRuntimeException("Failed to clean up domain 
resources and sub domains");
                 }
             } else {
                 List<AccountVO> accountsForCleanup = 
_accountDao.findCleanupsForRemovedAccounts(domain.getId());
                 if (accountsForCleanup.isEmpty()) {
                     if (!_domainDao.remove(domain.getId())) {
-                        s_logger.error("Delete failed on domain " + 
domain.getName() + " (id: " + domain.getId()
-                                + "); please make sure all users and sub 
domains have been removed from the domain before deleting");
                         rollBackState = true;
-                        return false;
+                        throw new CloudRuntimeException("Please make sure all 
users and sub domains have been removed from the domain before deleting");
                     }
                 } else {
-                    s_logger.warn("Can't delete the domain yet because it has 
" + accountsForCleanup.size() + "accounts that need a cleanup");
                     rollBackState = true;
-                    return false;
+                    throw new CloudRuntimeException("Can't delete the domain 
yet because it has " + accountsForCleanup.size() + "accounts that need a 
cleanup");
                 }
             }
 
@@ -251,7 +247,10 @@ public class DomainManagerImpl implements DomainManager, 
DomainService, Manager
             return true;
         } catch (Exception ex) {
             s_logger.error("Exception deleting domain with id " + 
domain.getId(), ex);
-            return false;
+            if (ex instanceof CloudRuntimeException)
+                throw (CloudRuntimeException)ex;
+            else
+                return false;
         } finally {
             //when success is false
             if (rollBackState) {
-- 
1.7.9.5


Reply via email to