Subject: Fix for RM1154: Show proper error message for already delete object [pgadmin4]

From: Harshal Dhumal <[email-masked]>
Date: Tue, 26 Jul 2016 18:35:26 +0530

Hi,

PFA patch for rm1154.

Issue fixed: Show proper error message if try to delete already deleted
object.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 1b7882d..e35d076 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -599,6 +599,9 @@ class DatabaseView(PGChildNodeView):
                 return make_json_response(
                     success=0,
                     errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
                         'The specified database could not be found.\n'
                     )
                 )
diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
index f159a05..ac8b476 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
@@ -454,6 +454,17 @@ class CastView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified cast object could not be found.\n'
+                    )
+                )
+
             # drop cast
             result = res['rows'][0]
             sql = render_template("/".join([self.template_path, 'delete.sql']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
index f429356..5ae5a0f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
@@ -452,6 +452,17 @@ class EventTriggerView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=name)
 
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified event trigger could not be found.\n'
+                    )
+                )
+
             sql = render_template("/".join([self.template_path, 'delete.sql']), name=name, cascade=cascade)
             status, res = self.conn.execute_scalar(sql)
             if not status:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
index f4c1e9e..1f70a1a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
@@ -310,6 +310,18 @@ class ExtensionView(PGChildNodeView):
             status, name = self.conn.execute_scalar(SQL)
             if not status:
                 return internal_server_error(errormsg=name)
+
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified extension could not be found.\n'
+                    )
+                )
+
             # drop extension
             SQL = render_template("/".join(
                 [self.template_path, 'delete.sql']
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
index 8efd50f..2103f50 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
@@ -478,6 +478,17 @@ class ForeignDataWrapperView(PGChildNodeView):
             status, name = self.conn.execute_scalar(sql)
             if not status:
                 return internal_server_error(errormsg=name)
+
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified foreign data wrapper could not be found.\n'
+                    )
+                )
             # drop foreign data wrapper node
             sql = render_template("/".join([self.template_path, 'delete.sql']), name=name, cascade=cascade,
                                   conn=self.conn)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
index e4c71df..66a1ad2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/__init__.py
@@ -488,6 +488,18 @@ class ForeignServerView(PGChildNodeView):
             status, name = self.conn.execute_scalar(sql)
             if not status:
                 return internal_server_error(errormsg=name)
+
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified foreign server could not be found.\n'
+                    )
+                )
+
             # drop foreign server
             sql = render_template("/".join([self.template_path, 'delete.sql']), name=name, cascade=cascade,
                                   conn=self.conn)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
index eac0659..369d2a4 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/foreign_servers/user_mapping/__init__.py
@@ -499,11 +499,30 @@ class UserMappingView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=name)
 
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified foreign server could not be found.\n'
+                    )
+                )
+
             sql = render_template("/".join([self.template_path, 'properties.sql']), umid=umid, conn=self.conn)
             status, res = self.conn.execute_dict(sql)
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'The specified user mapping could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
 
             # drop user mapping
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
index 7b99024..cf7d126 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/__init__.py
@@ -616,6 +616,18 @@ It may have been removed by another user.
             status, name = self.conn.execute_scalar(SQL)
             if not status:
                 return internal_server_error(errormsg=name)
+
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified schema could not be found.\n'
+                    )
+                )
+
             # drop schema
             SQL = render_template(
                 "/".join([self.template_path, 'sql/delete.sql']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
index 4492a79..29fbe61 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/collations/__init__.py
@@ -457,6 +457,17 @@ class CollationView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=name)
 
+            if name is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified collation could not be found.\n'
+                    )
+                )
+
             SQL = render_template("/".join([self.template_path,
                                             'delete.sql']),
                                   name=name, cascade=cascade,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
index f9a2d82..2345627 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/__init__.py
@@ -567,6 +567,17 @@ AND relkind != 'c'))"""
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified domain could not be found.\n'
+                    )
+                )
+
             name, basensp = res['rows'][0]
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
index 8db6b04..cf5fa35 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/domain_constraints/__init__.py
@@ -441,6 +441,17 @@ class DomainConstraintView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified domain constraint could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
index 7b698c0..a372107 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/__init__.py
@@ -707,6 +707,17 @@ AND relkind != 'c'))"""
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified foreign table could not be found.\n'
+                    )
+                )
+
             name, basensp = res['rows'][0]
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
index 69f0348..2aa6eca 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_configurations/__init__.py
@@ -567,10 +567,16 @@ class FtsConfigurationView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
-            if len(res['rows']) == 0:
-                return gone(_("""
-                        Could not find the FTS Configuration node to delete.
-                    """))
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified FTS configuration could not be found.\n'
+                    )
+                )
 
             # Drop FTS Configuration
             result = res['rows'][0]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
index 987cd6d..5ff86a3 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_dictionaries/__init__.py
@@ -553,10 +553,16 @@ class FtsDictionaryView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
-            if len(res['rows']) == 0:
-                return gone(_("""
-                        Could not find the FTS Dictionary node to delete.
-                    """))
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified FTS dictionary could not be found.\n'
+                    )
+                )
 
             # Drop FTS Dictionary
             result = res['rows'][0]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py
index d6aae60..ec152ba 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_parser/__init__.py
@@ -487,8 +487,16 @@ class FtsParserView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
-            if len(res['rows']) == 0:
-                return gone(_("Could not find the FTS Parser node."))
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified FTS parser could not be found.\n'
+                    )
+                )
 
             # Drop fts Parser
             result = res['rows'][0]
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
index 6612998..dfd1ae1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/fts_templates/__init__.py
@@ -449,6 +449,17 @@ class FtsTemplateView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified FTS template could not be found.\n'
+                    )
+                )
+
             # Drop fts template
             result = res['rows'][0]
             sql = render_template("/".join([self.template_path, 'delete.sql']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index 9873ba3..c2a48a2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -788,6 +788,17 @@ class FunctionView(PGChildNodeView, DataTypeReader):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified function could not be found.\n'
+                    )
+                )
+
             name, func_args, nspname = res['rows'][0]
 
             SQL = render_template("/".join([self.sql_template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
index 5f55e97..c0e18fc 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py
@@ -383,6 +383,17 @@ class SequenceView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified sequence could not be found.\n'
+                    )
+                )
+
             SQL = render_template("/".join([self.template_path, 'delete.sql']), data=res['rows'][0], cascade=cascade)
             status, res = self.conn.execute_scalar(SQL)
             if not status:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index e67add5..fc838ac 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -1500,6 +1500,18 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
             status, res = self.conn.execute_dict(SQL)
             if not status:
                 return internal_server_error(errormsg=res)
+
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified table could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
index c860316..2bd513d 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
@@ -594,6 +594,17 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified column could not be found.\n'
+                    )
+                )
+
             data = dict(res['rows'][0])
             # We will add table & schema as well
             data['schema'] = self.schema
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
index 4aa9552..2361d89 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/__init__.py
@@ -508,6 +508,17 @@ class CheckConstraintView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified check constraint could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index bb9c7ea..23f80d0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -621,6 +621,17 @@ class ExclusionConstraintView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified exclusion constraint could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
             data['schema'] = self.schema
             data['table'] = self.table
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
index 5a05a91..446d247 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/__init__.py
@@ -683,6 +683,17 @@ class ForeignKeyConstraintView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified foreign key could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
             data['schema'] = self.schema
             data['table'] = self.table
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
index a5ee551..bab9137 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/__init__.py
@@ -643,6 +643,17 @@ class IndexConstraintView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=_(
+                        'Error: Object not found.'
+                    ),
+                    info=_(
+                        'The specified constraint could not be found.\n'
+                    )
+                )
+
             data = res['rows'][0]
             data['schema'] = self.schema
             data['table'] = self.table
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
index e2cce0b..3b98dcf 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/__init__.py
@@ -638,6 +638,17 @@ class IndexesView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified index could not be found.\n'
+                    )
+                )
+
             data = dict(res['rows'][0])
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
index c256e40..ccd1a77 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/rules/__init__.py
@@ -377,6 +377,18 @@ class RuleView(PGChildNodeView):
             status, res_data = self.conn.execute_dict(SQL)
             if not status:
                 return internal_server_error(errormsg=res_data)
+
+            if not res_data['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified rule could not be found.\n'
+                    )
+                )
+
             # drop rule
             rset = res_data['rows'][0]
             SQL = render_template("/".join(
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
index 35559ea..ae8fb3f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/__init__.py
@@ -623,6 +623,17 @@ class TriggerView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified trigger could not be found.\n'
+                    )
+                )
+
             data = dict(res['rows'][0])
 
             SQL = render_template("/".join([self.template_path,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
index dc790ce..472dfe7 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py
@@ -965,6 +965,17 @@ class TypeView(PGChildNodeView, DataTypeReader):
             if not status:
                 return internal_server_error(errormsg=res)
 
+            if not res['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified type could not be found.\n'
+                    )
+                )
+
             # Making copy of output for future use
             data = dict(res['rows'][0])
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index efd1247..f307e7c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -575,6 +575,17 @@ class ViewNode(PGChildNodeView, VacuumSettings):
             if not status:
                 return internal_server_error(errormsg=res_data)
 
+            if not res_data['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified view could not be found.\n'
+                    )
+                )
+
             # drop view
             SQL = render_template(
                 "/".join([
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py b/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py
index 16c617a..4f4de4f 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/__init__.py
@@ -430,6 +430,18 @@ class ResourceGroupView(NodeView):
             status, rgname = self.conn.execute_scalar(sql)
             if not status:
                 return internal_server_error(errormsg=rgname)
+
+            if rgname is None:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified resource group could not be found.\n'
+                    )
+                )
+
             # drop resource group
             sql = render_template("/".join([self.template_path, 'delete.sql']), rgname=rgname, conn=self.conn)
             status, res = self.conn.execute_scalar(sql)
diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
index 6137a69..4ea284c 100644
--- a/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/tablespaces/__init__.py
@@ -368,9 +368,15 @@ class TablespaceView(PGChildNodeView):
             if not status:
                 return internal_server_error(errormsg=rset)
 
-            if len(rset['rows']) != 1:
-                return gone(
-                    errormsg=gettext("Could not find the tablespace on the server.")
+            if not rset['rows']:
+                return make_json_response(
+                    success=0,
+                    errormsg=gettext(
+                        'Error: Object not found.'
+                    ),
+                    info=gettext(
+                        'The specified tablespace could not be found.\n'
+                    )
                 )
 
             # drop tablespace

-- 
Sent via pgadmin-hackers mailing list ([email-masked])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

---

From: Dave Page <[email-masked]>
Date: Tue, 26 Jul 2016 14:40:13 +0100

Thanks, patch applied.

On Tue, Jul 26, 2016 at 2:05 PM, Harshal Dhumal
<[email-masked]> wrote:
> Harshal Dhumal
> Software Engineer

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company