Skip to content

Commit 8ed9727

Browse files
committed
Changes to show the error from the backend
1 parent b884a85 commit 8ed9727

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

backend/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ app.use((error, req, res, next) => {
240240
res.status(error.status || 500).send({
241241
error: {
242242
status: error.status || 500,
243-
message: error.message || "Internal Server error",
243+
message: error || "Internal Server error",
244244
},
245245
});
246246
});

frontend/public/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,9 @@ $(document).ready(function () {
276276
success: function (response) {
277277
$("#column-multiline").empty();
278278
if (response.error) {
279+
console.log(response.error);
279280
showNotification(
280-
"An error occurred, check your backend connection to cloud services",
281+
"An error occurred:" + response.error.message,
281282
"is-danger"
282283
);
283284
$("#analyzebtn").attr("disabled", true);

jobs/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const naturalLanguageUnderstanding = new NaturalLanguageUnderstandingV1({
1313
serviceUrl: process.env.NLU_JOB_URL,
1414
});
1515

16+
function getCosClient() {
1617
var config = {
1718
endpoint:
1819
process.env.COS_ENDPOINT ||
@@ -23,6 +24,8 @@ var config = {
2324
};
2425

2526
var cosClient = new myCOS.S3(config);
27+
return cosClient;
28+
}
2629
getBucketContents(process.env.COS_BUCKETNAME);
2730
/**
2831
* Get contents of a COS Bucket
@@ -31,8 +34,9 @@ getBucketContents(process.env.COS_BUCKETNAME);
3134
* @return {*}
3235
*/
3336
function getBucketContents(bucketName) {
37+
let cos = getCosClient();
3438
console.log(`Retrieving bucket contents from: ${bucketName}`);
35-
return cosClient
39+
return cos
3640
.listObjects({ Bucket: bucketName })
3741
.promise()
3842
.then((data) => {
@@ -57,8 +61,9 @@ function getBucketContents(bucketName) {
5761
* @return {*}
5862
*/
5963
function getItem(bucketName, itemName) {
64+
let cos = getCosClient();
6065
console.log(`Retrieving item from bucket: ${bucketName}, key: ${itemName}`);
61-
return cosClient
66+
return cos
6267
.getObject({
6368
Bucket: bucketName,
6469
Key: itemName,
@@ -116,8 +121,9 @@ function getItem(bucketName, itemName) {
116121
* @return {*}
117122
*/
118123
function createJsonFile(bucketName, itemName, fileText) {
124+
let cos = getCosClient();
119125
console.log(`Creating new item: ${itemName}`);
120-
return cosClient
126+
return cos
121127
.putObject({
122128
Bucket: bucketName,
123129
Key: itemName,

0 commit comments

Comments
 (0)