From 403cd717a997391619161d233b13d9b080d24248 Mon Sep 17 00:00:00 2001 From: Wenyi Luo Date: Tue, 19 May 2020 18:00:26 +0800 Subject: [PATCH 1/3] show error message in log --- Composer/plugins/azurePublish/src/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Composer/plugins/azurePublish/src/index.ts b/Composer/plugins/azurePublish/src/index.ts index f74b732337..6f87002e3b 100644 --- a/Composer/plugins/azurePublish/src/index.ts +++ b/Composer/plugins/azurePublish/src/index.ts @@ -195,11 +195,16 @@ class AzurePublisher { } } catch (error) { console.log(error); + if (typeof error === 'object') { + this.logMessages.push(JSON.stringify(error)); + } else { + this.logMessages.push(error); + } // update status and history const status = this.getLoadingStatus(botId, profileName, jobId); if (status) { status.status = 500; - status.result.message = error ? error.message : 'publish error'; + status.result.message = error && error.message ? error.message : 'publish error'; status.result.log = this.logMessages.join('\n'); await this.updateHistory(botId, profileName, { status: status.status, ...status.result }); this.removeLoadingStatus(botId, profileName, jobId); @@ -319,7 +324,11 @@ class AzurePublisher { return response; } catch (err) { console.log(err); - this.logMessages.push(err.message); + if (typeof err === 'object') { + this.logMessages.push(JSON.stringify(err)); + } else { + this.logMessages.push(err); + } const response = { status: 500, result: { From 2f1ac0c3125657d1a0d24fa52c2216e1a29a88e4 Mon Sep 17 00:00:00 2001 From: Wenyi Luo Date: Wed, 20 May 2020 11:47:43 +0800 Subject: [PATCH 2/3] fix comments --- Composer/plugins/azurePublish/src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Composer/plugins/azurePublish/src/index.ts b/Composer/plugins/azurePublish/src/index.ts index 6f87002e3b..b27cf99b92 100644 --- a/Composer/plugins/azurePublish/src/index.ts +++ b/Composer/plugins/azurePublish/src/index.ts @@ -195,7 +195,7 @@ class AzurePublisher { } } catch (error) { console.log(error); - if (typeof error === 'object') { + if (typeof error === 'object' && !(error instanceof Error)) { this.logMessages.push(JSON.stringify(error)); } else { this.logMessages.push(error); @@ -204,7 +204,7 @@ class AzurePublisher { const status = this.getLoadingStatus(botId, profileName, jobId); if (status) { status.status = 500; - status.result.message = error && error.message ? error.message : 'publish error'; + status.result.message = error?.message || 'publish error'; status.result.log = this.logMessages.join('\n'); await this.updateHistory(botId, profileName, { status: status.status, ...status.result }); this.removeLoadingStatus(botId, profileName, jobId); @@ -324,7 +324,7 @@ class AzurePublisher { return response; } catch (err) { console.log(err); - if (typeof err === 'object') { + if (typeof err === 'object' && !(err instanceof Error)) { this.logMessages.push(JSON.stringify(err)); } else { this.logMessages.push(err); From ebf0288f1ed1c1e8d59ecfbc7c359df6edc0752d Mon Sep 17 00:00:00 2001 From: Wenyi Luo Date: Thu, 21 May 2020 11:56:29 +0800 Subject: [PATCH 3/3] fix comments --- Composer/plugins/azurePublish/src/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Composer/plugins/azurePublish/src/index.ts b/Composer/plugins/azurePublish/src/index.ts index b27cf99b92..fd5a3d61df 100644 --- a/Composer/plugins/azurePublish/src/index.ts +++ b/Composer/plugins/azurePublish/src/index.ts @@ -195,7 +195,9 @@ class AzurePublisher { } } catch (error) { console.log(error); - if (typeof error === 'object' && !(error instanceof Error)) { + if (error instanceof Error) { + this.logMessages.push(error.message); + } else if (typeof error === 'object') { this.logMessages.push(JSON.stringify(error)); } else { this.logMessages.push(error); @@ -204,7 +206,7 @@ class AzurePublisher { const status = this.getLoadingStatus(botId, profileName, jobId); if (status) { status.status = 500; - status.result.message = error?.message || 'publish error'; + status.result.message = this.logMessages[this.logMessages.length - 1]; status.result.log = this.logMessages.join('\n'); await this.updateHistory(botId, profileName, { status: status.status, ...status.result }); this.removeLoadingStatus(botId, profileName, jobId); @@ -324,7 +326,9 @@ class AzurePublisher { return response; } catch (err) { console.log(err); - if (typeof err === 'object' && !(err instanceof Error)) { + if (err instanceof Error) { + this.logMessages.push(err.message); + } else if (typeof err === 'object') { this.logMessages.push(JSON.stringify(err)); } else { this.logMessages.push(err); @@ -334,7 +338,7 @@ class AzurePublisher { result: { id: jobId, time: new Date(), - message: 'Publish Fail', + message: this.logMessages[this.logMessages.length - 1], log: this.logMessages.join('\n'), comment: metadata.comment, },