From bc60650eb5f432e34ea0c5ced4acd1477e6b3583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Thu, 29 Aug 2024 22:20:17 +0200 Subject: [PATCH] #1627: improve error handling for publish --- lib/metadataTypes/Journey.js | 39 +++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/metadataTypes/Journey.js b/lib/metadataTypes/Journey.js index ec007fcc5..27a4ba52d 100644 --- a/lib/metadataTypes/Journey.js +++ b/lib/metadataTypes/Journey.js @@ -1702,18 +1702,33 @@ class Journey extends MetadataType { executedKeyArr.push(await this._checkPublishStatus(statusUrl, key)); } } catch (ex) { - if (ex.message === 'Cannot publish interaction in Published status.') { - Util.logger.info( - ` - ${this.definition.type} ${key} is already published` - ); - } else if (ex.message === 'Cannot publish interaction in Stopped status.') { - Util.logger.warn( - ` - ${this.definition.type} ${key} is already published but stopped. Please resume it manually.` - ); - } else { - Util.logger.error( - `Failed to publish ${this.definition.type} ${key}: ${ex.message}` - ); + switch (ex.message) { + case 'Cannot publish interaction in Published status.': { + Util.logger.info( + ` - ${this.definition.type} ${key}/${version} is already published.` + ); + + break; + } + case 'Cannot publish interaction in Stopped status.': { + Util.logger.warn( + ` - ${this.definition.type} ${key}/${version} is stopped. Please create a new version and publish that.` + ); + + break; + } + case 'Cannot publish interaction in Paused status.': { + Util.logger.warn( + ` - ${this.definition.type} ${key}/${version} is already published but currently paused. Run 'mcdev resume' instead.` + ); + + break; + } + default: { + Util.logger.error( + `Failed to publish ${this.definition.type} ${key}: ${ex.message}` + ); + } } } break;