Fixed incorrect handling of the code smell for the reject API call

This commit is contained in:
Akshay Joshi 2024-06-17 18:22:38 +05:30
parent 3706c3126a
commit 2b04f3ca1d
26 changed files with 44 additions and 42 deletions

View File

@ -35,8 +35,10 @@ Bug fixes
| `Issue #7295 <https://github.com/pgadmin-org/pgadmin4/issues/7295>`_ - Fixed new line indentation in query editor and add a user preference to disable it. | `Issue #7295 <https://github.com/pgadmin-org/pgadmin4/issues/7295>`_ - Fixed new line indentation in query editor and add a user preference to disable it.
| `Issue #7306 <https://github.com/pgadmin-org/pgadmin4/issues/7306>`_ - Ensure that a user can connect to a server using SSL certificates and identity files from a shared storage. | `Issue #7306 <https://github.com/pgadmin-org/pgadmin4/issues/7306>`_ - Ensure that a user can connect to a server using SSL certificates and identity files from a shared storage.
| `Issue #7414 <https://github.com/pgadmin-org/pgadmin4/issues/7414>`_ - Add support for comments on RLS policy object. | `Issue #7414 <https://github.com/pgadmin-org/pgadmin4/issues/7414>`_ - Add support for comments on RLS policy object.
| `Issue #7476 <https://github.com/pgadmin-org/pgadmin4/issues/7476>`_ - Fixed an issue where changing a column name should reflect in all the constraints in table object dialog and ERD table dialog.
| `Issue #7481 <https://github.com/pgadmin-org/pgadmin4/issues/7481>`_ - Fixed an issue where dark theme shows white background when all tabs are closed. | `Issue #7481 <https://github.com/pgadmin-org/pgadmin4/issues/7481>`_ - Fixed an issue where dark theme shows white background when all tabs are closed.
| `Issue #7516 <https://github.com/pgadmin-org/pgadmin4/issues/7516>`_ - Ensure preferences can be loaded using preferences.json. | `Issue #7516 <https://github.com/pgadmin-org/pgadmin4/issues/7516>`_ - Ensure preferences can be loaded using preferences.json.
| `Issue #7528 <https://github.com/pgadmin-org/pgadmin4/issues/7528>`_ - Fixed an issue where backslash breaks syntax highlighting. | `Issue #7528 <https://github.com/pgadmin-org/pgadmin4/issues/7528>`_ - Fixed an issue where backslash breaks syntax highlighting.
| `Issue #7536 <https://github.com/pgadmin-org/pgadmin4/issues/7536>`_ - Search Objects dialog should focus on search input on open. | `Issue #7536 <https://github.com/pgadmin-org/pgadmin4/issues/7536>`_ - Search Objects dialog should focus on search input on open.
| `Issue #7555 <https://github.com/pgadmin-org/pgadmin4/issues/7555>`_ - Fixed an issue where query tool shortcuts for find/replace are not working. | `Issue #7555 <https://github.com/pgadmin-org/pgadmin4/issues/7555>`_ - Fixed an issue where query tool shortcuts for find/replace are not working.
| `Issue #7556 <https://github.com/pgadmin-org/pgadmin4/issues/7556>`_ - Fixed migration failure while using external database.

View File

@ -91,7 +91,7 @@ define('pgadmin.node.cast', [
resolve(data); resolve(data);
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} else { } else {
data = []; data = [];

View File

@ -100,7 +100,7 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
data = res.data.data; data = res.data.data;
resolve(data); resolve(data);
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} else { } else {
resolve(data); resolve(data);
@ -127,7 +127,7 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
data = res.data.data; data = res.data.data;
resolve(data); resolve(data);
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} else { } else {
resolve(data); resolve(data);
@ -155,7 +155,7 @@ function getRangeSchema(nodeObj, treeNodeInfo, itemNodeData) {
data = res.data.data; data = res.data.data;
resolve(data); resolve(data);
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} else { } else {
resolve(data); resolve(data);

View File

@ -112,7 +112,7 @@ define('pgadmin.node.subscription', [
} }
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }
}); });

View File

@ -124,7 +124,7 @@ export function getNodeAjaxOptions(url, nodeObj, treeNodeInfo, itemNodeData, par
otherParams.useCache && cacheNode.cache(nodeObj.type + '#' + url, treeNodeInfo, cacheLevel, data); otherParams.useCache && cacheNode.cache(nodeObj.type + '#' + url, treeNodeInfo, cacheLevel, data);
resolve(transform(data)); resolve(transform(data));
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error('Something went wrong'));
}); });
} else { } else {
// To fetch only options from cache, we do not need time from 'at' // To fetch only options from cache, we do not need time from 'at'

View File

@ -82,7 +82,7 @@ export function AwsInstanceDetails(props) {
resolve(data); resolve(data);
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} else { } else {
resolve(options); resolve(options);

View File

@ -72,7 +72,7 @@ export function AzureCredentials(props) {
}) })
.catch((error)=>{ .catch((error)=>{
clearInterval(interval); clearInterval(interval);
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
}); });
}, 1000); }, 1000);
}); });

View File

@ -122,7 +122,7 @@ class AzureCredSchema extends BaseUISchema {
})); }));
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }
}); });
@ -152,7 +152,7 @@ class AzureCredSchema extends BaseUISchema {
}); });
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }
}); });

View File

@ -87,7 +87,7 @@ export function GoogleCredentials(props) {
}) })
.catch((error)=>{ .catch((error)=>{
clearInterval(interval); clearInterval(interval);
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
}); });
countdown = countdown - 1; countdown = countdown - 1;
}, 1000); }, 1000);

View File

@ -68,13 +68,13 @@ class GoogleCredSchema extends BaseUISchema{
resolve(); resolve();
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }
}); });
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }
}); });

View File

@ -87,7 +87,7 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
} else if (msg == 'CRYPTKEY_NOT_SET') { } else if (msg == 'CRYPTKEY_NOT_SET') {
reject(new Error(gettext('The master password is not set.'))); reject(new Error(gettext('The master password is not set.')));
} }
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}) })
@ -116,7 +116,7 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
} else if (msg == 'CRYPTKEY_NOT_SET') { } else if (msg == 'CRYPTKEY_NOT_SET') {
reject(new Error(gettext('The master password is not set.'))); reject(new Error(gettext('The master password is not set.')));
} }
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}); });
@ -133,7 +133,7 @@ export default function ObjectNodeProperties({panelId, node, treeNodeInfo, nodeD
resolve(res.data.data); resolve(res.data.data);
}).catch((err)=>{ }).catch((err)=>{
onError(err); onError(err);
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}; };

View File

@ -114,7 +114,7 @@ function RightPanel({ schema, ...props }) {
try { try {
resolve(props.initValues); resolve(props.initValues);
} catch (error) { } catch (error) {
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}); });

View File

@ -210,7 +210,7 @@ export function showChangeServerPassword() {
onClose(); onClose();
}) })
.catch((error)=>{ .catch((error)=>{
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
}); });
}); });
}} }}
@ -237,7 +237,7 @@ export function showChangeUserPassword(url) {
resolve(res.data); resolve(res.data);
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}} }}
@ -263,7 +263,7 @@ export function showChangeUserPassword(url) {
onClose(); onClose();
pgAdmin.Browser.notifier.success(res.data.info); pgAdmin.Browser.notifier.success(res.data.info);
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}} }}
@ -336,7 +336,7 @@ export function showChangeOwnership() {
resolve(respData.data); resolve(respData.data);
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }
}); });

View File

@ -95,7 +95,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
onSave?.(res.data); onSave?.(res.data);
onClose(); onClose();
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
@ -111,7 +111,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
resolve(res.data.data); resolve(res.data.data);
}).catch((err)=>{ }).catch((err)=>{
onError(err); onError(err);
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}; };
@ -161,7 +161,7 @@ function UtilityViewContent({panelId, schema, treeNodeInfo, actionType, formType
} else if(err.message){ } else if(err.message){
console.error('error msg', err.message); console.error('error msg', err.message);
} }
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} }

View File

@ -22,7 +22,7 @@ export function setPGCSRFToken(header, token) {
return config; return config;
}, function (error) { }, function (error) {
return Promise.reject(new Error(error)); return Promise.reject(error instanceof Error ? error : Error('Something went wrong'));
}); });
} }

View File

@ -27,10 +27,10 @@ export function openSocket(namespace, options) {
resolve(socketObj); resolve(socketObj);
}); });
socketObj.on('connect_error', (err)=>{ socketObj.on('connect_error', (err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
socketObj.on('disconnect', (err)=>{ socketObj.on('disconnect', (err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
} }

View File

@ -265,7 +265,7 @@ define([
}).then((response)=> { }).then((response)=> {
resolve(response.data.data); resolve(response.data.data);
}).catch((err)=>{ }).catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}} }}

View File

@ -429,7 +429,7 @@ export default function DebuggerArgumentComponent({ debuggerInfo, restartDebug,
try { try {
resolve(debuggerArgsData.current); resolve(debuggerArgsData.current);
} catch (error) { } catch (error) {
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}); });

View File

@ -486,7 +486,7 @@ export default class ERDTool extends React.Component {
}) })
.catch((err)=>{ .catch((err)=>{
console.error(err); console.error(err);
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
const {x, y} = this.diagram.getEngine().getRelativeMousePoint(e); const {x, y} = this.diagram.getEngine().getRelativeMousePoint(e);

View File

@ -388,11 +388,11 @@ export default function SearchObjects({nodeData}) {
}) })
.catch((err)=>{ .catch((err)=>{
pgAdmin.Browser.notifier.error(parseApiError(err)); pgAdmin.Browser.notifier.error(parseApiError(err));
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} catch (error) { } catch (error) {
pgAdmin.Browser.notifier.error(parseApiError(error)); pgAdmin.Browser.notifier.error(parseApiError(error));
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}); });
}; };

View File

@ -721,7 +721,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
}); });
} else { } else {
selectConn(currSelectedConn, currConnected, false); selectConn(currSelectedConn, currConnected, false);
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}); });
}); });
@ -763,7 +763,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
} }
updateQueryToolConnection(connectionData, true) updateQueryToolConnection(connectionData, true)
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}).then(()=>{ }).then(()=>{
resolve(); resolve();
onClose(); onClose();

View File

@ -88,7 +88,7 @@ export default function FilterDialog({onClose, onSave}) {
filterSchemaObj.setColumnOptions((columns||[]).map((c)=>({label: c, value: c}))); filterSchemaObj.setColumnOptions((columns||[]).map((c)=>({label: c, value: c})));
resolve(filterData); resolve(filterData);
} catch (error) { } catch (error) {
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}; };
getFilterData(); getFilterData();
@ -109,7 +109,7 @@ export default function FilterDialog({onClose, onSave}) {
reject(new Error(respData.data.result)); reject(new Error(respData.data.result));
} }
} catch (error) { } catch (error) {
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}; };
setFilterData(); setFilterData();

View File

@ -169,7 +169,7 @@ export default function MacrosDialog({onClose, onSave}) {
onSave(respData.filter((m) => Boolean(m.name))); onSave(respData.filter((m) => Boolean(m.name)));
onClose(); onClose();
} catch (error) { } catch (error) {
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
} }
}; };
setMacros(); setMacros();

View File

@ -75,7 +75,7 @@ class NewConnectionSchema extends BaseUISchema {
resolve(groupedOptions); resolve(groupedOptions);
}) })
.catch((error)=>{ .catch((error)=>{
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
}); });
}); });
} }
@ -97,7 +97,7 @@ class NewConnectionSchema extends BaseUISchema {
resolve(respData.data.result.data); resolve(respData.data.result.data);
}) })
.catch((error)=>{ .catch((error)=>{
reject(new Error(error)); reject(error instanceof Error ? error : Error(gettext('Something went wrong')));
}); });
}); });
} }

View File

@ -50,7 +50,7 @@ async function registerAutocomplete(editor, api, transId) {
}) })
.catch((err) => { .catch((err) => {
onAvailable(); onAvailable();
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); });
}); });

View File

@ -364,7 +364,7 @@ function UserManagementDialog({onClose}) {
onClose(); onClose();
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
} catch (error) { } catch (error) {
reject(parseApiError(error)); reject(parseApiError(error));
@ -402,7 +402,7 @@ function UserManagementDialog({onClose}) {
resolve({userManagement:res.data}); resolve({userManagement:res.data});
}) })
.catch((err)=>{ .catch((err)=>{
reject(new Error(err)); reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
}); });
}); }} }); }}
schema={new UserManagementSchema(authSourcesOptions, roleOptions)} schema={new UserManagementSchema(authSourcesOptions, roleOptions)}