Skip to content

Commit aa679e0

Browse files
adityatoshniwalakshay-joshi
authored andcommitted
Replace the generic exception class with a more specific one to fix SonarQube issues.
1 parent d262128 commit aa679e0

File tree

14 files changed

+73
-48
lines changed

14 files changed

+73
-48
lines changed

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/columns/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ExecuteError
1616
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
1717
import DataTypeReader
1818
from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db, \
@@ -52,7 +52,7 @@ def get_parent(conn, tid, template_path=None):
5252
'get_parent.sql']), tid=tid)
5353
status, rset = conn.execute_2darray(SQL)
5454
if not status:
55-
raise Exception(rset)
55+
raise ExecuteError(rset)
5656

5757
schema = ''
5858
table = ''
@@ -211,7 +211,7 @@ def get_formatted_columns(conn, tid, data, other_columns,
211211

212212
status, res = conn.execute_dict(SQL)
213213
if not status:
214-
raise Exception(res)
214+
raise ExecuteError(res)
215215

216216
all_columns = res['rows']
217217
edit_types = {}

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/compound_triggers/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
1717
import trigger_definition
1818
from functools import wraps
@@ -50,7 +50,7 @@ def get_parent(conn, tid, template_path=None):
5050
'get_parent.sql']), tid=tid)
5151
status, rset = conn.execute_2darray(SQL)
5252
if not status:
53-
raise Exception(rset)
53+
raise ExecuteError(rset)
5454

5555
schema = ''
5656
table = ''
@@ -105,7 +105,7 @@ def get_sql(conn, data, tid, trid, datlastsysoid, template_path=None):
105105

106106
status, res = conn.execute_dict(sql)
107107
if not status:
108-
raise Exception(res)
108+
raise ExecuteError(res)
109109
elif len(res['rows']) == 0:
110110
raise ObjectGone(
111111
_('Could not find the compound trigger in the table.'))
@@ -162,7 +162,7 @@ def get_reverse_engineered_sql(conn, **kwargs):
162162

163163
status, res = conn.execute_dict(SQL)
164164
if not status:
165-
raise Exception(res)
165+
raise ExecuteError(res)
166166

167167
if len(res['rows']) == 0:
168168
raise ObjectGone(

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/check_constraint/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from functools import wraps
1717

1818

@@ -48,7 +48,7 @@ def get_parent(conn, tid, template_path=None):
4848
'get_parent.sql']), tid=tid)
4949
status, rset = conn.execute_2darray(SQL)
5050
if not status:
51-
raise Exception(rset)
51+
raise ExecuteError(rset)
5252

5353
schema = ''
5454
table = ''
@@ -163,7 +163,7 @@ def get_sql(conn, data, tid, cid=None, template_path=None):
163163
tid=tid, cid=cid)
164164
status, res = conn.execute_dict(sql)
165165
if not status:
166-
raise Exception(res)
166+
raise ExecuteError(res)
167167

168168
if len(res['rows']) == 0:
169169
raise ObjectGone(

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from functools import wraps
1717

1818

@@ -48,7 +48,7 @@ def get_parent(conn, tid, template_path=None):
4848
'get_parent.sql']), tid=tid)
4949
status, rset = conn.execute_2darray(SQL)
5050
if not status:
51-
raise Exception(rset)
51+
raise ExecuteError(rset)
5252

5353
schema = ''
5454
table = ''
@@ -191,7 +191,7 @@ def get_sql(conn, data, did, tid, exid=None, template_path=None):
191191
did=did, tid=tid, cid=exid)
192192
status, res = conn.execute_dict(sql)
193193
if not status:
194-
raise Exception(res)
194+
raise ExecuteError(res)
195195

196196
if len(res['rows']) == 0:
197197
raise ObjectGone(

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from functools import wraps
1717

1818

@@ -110,7 +110,7 @@ def search_coveringindex(conn, tid, cols, template_path=None):
110110
tid=tid)
111111
status, constraints = conn.execute_dict(SQL)
112112
if not status:
113-
raise Exception(constraints)
113+
raise ExecuteError(constraints)
114114

115115
for constraint in constraints['rows']:
116116
sql = render_template(
@@ -120,7 +120,7 @@ def search_coveringindex(conn, tid, cols, template_path=None):
120120
status, rest = conn.execute_dict(sql)
121121

122122
if not status:
123-
raise Exception(rest)
123+
raise ExecuteError(rest)
124124

125125
index_cols = set()
126126
for r in rest['rows']:
@@ -146,7 +146,7 @@ def get_parent(conn, tid, template_path=None):
146146
'get_parent.sql']), tid=tid)
147147
status, rset = conn.execute_2darray(SQL)
148148
if not status:
149-
raise Exception(rset)
149+
raise ExecuteError(rset)
150150

151151
schema = ''
152152
table = ''
@@ -254,7 +254,7 @@ def get_sql(conn, data, tid, fkid=None, template_path=None):
254254

255255
status, res = conn.execute_dict(col_sql)
256256
if not status:
257-
raise Exception(res)
257+
raise ExecuteError(res)
258258

259259
columns = []
260260
for row in res['rows']:
@@ -290,7 +290,7 @@ def _get_properties_for_fk_const(tid, fkid, data, template_path, conn):
290290
tid=tid, cid=fkid)
291291
status, res = conn.execute_dict(sql)
292292
if not status:
293-
raise Exception(res)
293+
raise ExecuteError(res)
294294

295295
if len(res['rows']) == 0:
296296
raise ObjectGone(

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from functools import wraps
1717

1818

@@ -48,7 +48,7 @@ def get_parent(conn, tid, template_path=None):
4848
'get_parent.sql']), tid=tid)
4949
status, rset = conn.execute_2darray(SQL)
5050
if not status:
51-
raise Exception(rset)
51+
raise ExecuteError(rset)
5252

5353
schema = ''
5454
table = ''
@@ -195,7 +195,7 @@ def get_sql(conn, data, did, tid, ctype, cid=None, template_path=None):
195195
constraint_type=ctype)
196196
status, res = conn.execute_dict(sql)
197197
if not status:
198-
raise Exception(res)
198+
raise ExecuteError(res)
199199

200200
if len(res['rows']) == 0:
201201
raise ObjectGone(

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/indexes/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from functools import wraps
1717

1818

@@ -48,7 +48,7 @@ def get_parent(conn, tid, template_path=None):
4848
'get_parent.sql']), tid=tid)
4949
status, rset = conn.execute_2darray(SQL)
5050
if not status:
51-
raise Exception(rset)
51+
raise ExecuteError(rset)
5252

5353
schema = ''
5454
table = ''
@@ -290,7 +290,7 @@ def get_reverse_engineered_sql(conn, **kwargs):
290290

291291
status, res = conn.execute_dict(SQL)
292292
if not status:
293-
raise Exception(res)
293+
raise ExecuteError(res)
294294

295295
if len(res['rows']) == 0:
296296
raise ObjectGone(_('Could not find the index in the table.'))

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/row_security_policies/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from functools import wraps
1717

1818

@@ -49,7 +49,7 @@ def get_parent(conn, tid, template_path=None):
4949
'get_parent.sql']), tid=tid)
5050
status, rset = conn.execute_2darray(SQL)
5151
if not status:
52-
raise Exception(rset)
52+
raise ExecuteError(rset)
5353

5454
schema = ''
5555
table = ''
@@ -119,7 +119,7 @@ def get_reverse_engineered_sql(conn, **kwargs):
119119

120120
status, res = conn.execute_dict(SQL)
121121
if not status:
122-
raise Exception(res)
122+
raise ExecuteError(res)
123123

124124
if len(res['rows']) == 0:
125125
raise ObjectGone(_('Could not find the policy in the table.'))

web/pgadmin/browser/server_groups/servers/databases/schemas/tables/triggers/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from flask import render_template
1313
from flask_babelex import gettext as _
1414
from pgadmin.utils.ajax import internal_server_error
15-
from pgadmin.utils.exception import ObjectGone
15+
from pgadmin.utils.exception import ObjectGone, ExecuteError
1616
from pgadmin.browser.server_groups.servers.databases.schemas.utils \
1717
import trigger_definition
1818
from config import PG_DEFAULT_DRIVER
@@ -52,7 +52,7 @@ def get_parent(conn, tid, template_path=None):
5252
'get_parent.sql']), tid=tid)
5353
status, rset = conn.execute_2darray(SQL)
5454
if not status:
55-
raise Exception(rset)
55+
raise ExecuteError(rset)
5656

5757
schema = ''
5858
table = ''
@@ -164,7 +164,7 @@ def get_sql(conn, **kwargs):
164164

165165
status, res = conn.execute_dict(sql)
166166
if not status:
167-
raise Exception(res)
167+
raise ExecuteError(res)
168168
elif len(res['rows']) == 0:
169169
raise ObjectGone(_('Could not find the trigger in the table.'))
170170

@@ -271,7 +271,7 @@ def get_reverse_engineered_sql(conn, **kwargs):
271271

272272
status, res = conn.execute_dict(SQL)
273273
if not status:
274-
raise Exception(res)
274+
raise ExecuteError(res)
275275

276276
if len(res['rows']) == 0:
277277
raise ObjectGone(_('Could not find the trigger in the table.'))

web/pgadmin/tools/sqleditor/command.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from pgadmin.tools.sqleditor.utils.save_changed_data import save_changed_data
2222
from pgadmin.tools.sqleditor.utils.get_column_types import get_columns_types
2323
from pgadmin.utils.preferences import Preferences
24-
from pgadmin.utils.exception import ObjectGone
24+
from pgadmin.utils.exception import ObjectGone, ExecuteError
2525

2626
from config import PG_DEFAULT_DRIVER
2727

@@ -187,7 +187,7 @@ def __init__(self, **kwargs):
187187

188188
status, result = conn.execute_dict(query)
189189
if not status:
190-
raise Exception(result)
190+
raise ExecuteError(result)
191191
if len(result['rows']) == 0:
192192
raise ObjectGone(
193193
gettext("The specified object could not be found."))
@@ -401,7 +401,7 @@ def get_all_columns_with_order(self, default_conn):
401401
)
402402
status, result = conn.execute_dict(query)
403403
if not status:
404-
raise Exception(result)
404+
raise ExecuteError(result)
405405

406406
for row in result['rows']:
407407
all_columns.append(row['attname'])
@@ -542,7 +542,7 @@ def get_primary_keys(self, default_conn=None):
542542

543543
status, result = conn.execute_dict(query)
544544
if not status:
545-
raise Exception(result)
545+
raise ExecuteError(result)
546546

547547
for row in result['rows']:
548548
pk_names += driver.qtIdent(conn, row['attname']) + ','
@@ -590,7 +590,7 @@ def get_all_columns_with_order(self, default_conn=None):
590590
status, result = conn.execute_dict(query)
591591

592592
if not status:
593-
raise Exception(result)
593+
raise ExecuteError(result)
594594

595595
for row in result['rows']:
596596
all_columns.append(row['attname'])
@@ -602,7 +602,7 @@ def get_all_columns_with_order(self, default_conn=None):
602602
)
603603
status, result = conn.execute_dict(query)
604604
if not status:
605-
raise Exception(result)
605+
raise ExecuteError(result)
606606

607607
for row in result['rows']:
608608
# Only append if not already present in the list
@@ -646,7 +646,7 @@ def has_oids(self, default_conn=None):
646646

647647
status, has_oids = conn.execute_scalar(query)
648648
if not status:
649-
raise Exception(has_oids)
649+
raise ExecuteError(has_oids)
650650

651651
else:
652652
raise Exception(
@@ -996,7 +996,7 @@ def __set_updatable_results_attrs(self, sql_path,
996996

997997
status, result = conn.execute_dict(query)
998998
if not status:
999-
raise Exception(result)
999+
raise ExecuteError(result)
10001000

10011001
self.nsp_name = result['rows'][0]['nspname']
10021002
self.object_name = result['rows'][0]['relname']

0 commit comments

Comments
 (0)