Skip to content

Commit

Permalink
HCK-8966: RE BigQuery Instance - Display error if dataset is not found (
Browse files Browse the repository at this point in the history
#61)

* HCK-8840: RE BigQuery Instance - Display error if dataset is not found

* fix
  • Loading branch information
AlikRakhmonov authored Dec 6, 2024
1 parent 3610fd6 commit 1895fa8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,6 @@
"MODAL_WINDOW___DB_CONNECTIONS_LIST_TITLE": "BigQuery Connections",
"MAIN_MENU___FORWARD_DB_BUCKETS": "BigQuery DDL...",
"MODAL_WINDOW___FE_SCRIPT_OPTION_CREATE": "Create",
"MODAL_WINDOW___FE_SCRIPT_OPTION_UPDATE": "Alter"
"MODAL_WINDOW___FE_SCRIPT_OPTION_UPDATE": "Alter",
"PROJECT_DATASET_NOT_FOUND": "The project or dataset could not be located in the BigQuery instance.\nDouble-check the project id and dataset name. Ensure the necessary permissions are in place to access the project or dataset.\nFor further assistance, please refer to the <a href=\"https://hackolade.com/help/ConnecttoaBigQueryinstance.html\">online documentation</a>."
}
13 changes: 13 additions & 0 deletions reverse_engineering/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,16 @@ const testConnection = async (connectionInfo, logger, cb) => {
const bigQueryHelper = createBigQueryHelper(client, log);
await bigQueryHelper.getDatasets();

const datasetName = connectionInfo.datasetId || connectionInfo.data?.databaseName;
if (datasetName) {
await bigQueryHelper.getTables(datasetName);
}

cb();
} catch (err) {
if (err.code === 404) {
err.customMsgCode = 'PROJECT_DATASET_NOT_FOUND';
}
cb(prepareError(logger, err));
}
};
Expand Down Expand Up @@ -92,6 +100,9 @@ const getDbCollectionsNames = async (connectionInfo, logger, cb, app) => {

cb(null, tablesByDataset);
} catch (err) {
if (err.code === 404) {
err.customMsgCode = 'PROJECT_DATASET_NOT_FOUND';
}
cb(prepareError(logger, err));
}
};
Expand Down Expand Up @@ -456,8 +467,10 @@ const getPartitioningRange = rangePartitioning => {

const prepareError = (logger, error) => {
const err = {
code: error.code,
message: error.message,
stack: error.stack,
customMsgCode: error.customMsgCode,
};

logger.log('error', err, 'Reverse Engineering error');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
"options": [{ "value": "", "label": "Google Cloud" }]
},
{
"inputLabel": "Project id",
"inputLabel": "Project ID",
"inputKeyword": "projectId",
"inputType": "text",
"inputPlaceholder": "Optional",
"inputTooltip": "Project ID on Google Cloud Platform"
},
{
"inputLabel": "Dataset id",
"inputLabel": "Dataset name",
"inputKeyword": "datasetId",
"inputType": "text",
"inputPlaceholder": "Optional",
"inputTooltip": "Dataset ID on Google Cloud Platform"
"inputTooltip": "Dataset name on Google Cloud Platform"
},
{
"inputLabel": "Key file",
Expand Down

0 comments on commit 1895fa8

Please sign in to comment.