From 49887f83db72b0378dd227b9f9097a57bde92110 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 26 Mar 2024 19:36:03 +0530 Subject: [PATCH] solved migration logger not adding the issue --- .../src/services/content-types.js | 12 ++++++------ .../contentstack-migration/src/utils/error-helper.js | 9 ++++++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/contentstack-migration/src/services/content-types.js b/packages/contentstack-migration/src/services/content-types.js index dc8a0d4e8a..089b161608 100644 --- a/packages/contentstack-migration/src/services/content-types.js +++ b/packages/contentstack-migration/src/services/content-types.js @@ -4,7 +4,7 @@ const Base = require('../modules/base'); // Utils -const { map: _map, safePromise, successHandler, errorHandler, constants } = require('../utils'); +const { map: _map, safePromise, successHandler, errorHandler, constants, errorHelper } = require('../utils'); // Map methods const { get, getMapInstance, getDataWithAction } = _map; const mapInstance = getMapInstance(); @@ -23,7 +23,7 @@ class ContentTypeService { const [err, result] = await safePromise(this.stackSDKInstance.contentType(id).fetch()); if (err) { - errorHandler(id, ContentType, method, err); + errorHelper(err); this.base.dispatch(callsite, id, err, 'apiError'); throw err; } @@ -36,7 +36,7 @@ class ContentTypeService { const data = getDataWithAction(id, mapInstance, action); const [err, result] = await safePromise(this.stackSDKInstance.contentType().create(data)); if (err) { - errorHandler(id, ContentType, 'POST', err); + errorHelper(err); this.base.dispatch(callsite, id, err, 'apiError'); throw err; } @@ -51,7 +51,7 @@ class ContentTypeService { const method = 'PUT'; const [err, result] = await safePromise(data.update()); if (err) { - errorHandler(data.uid, ContentType, method, err); + errorHelper(err); this.base.dispatch(callsite, data.uid, err, 'apiError'); throw err; } @@ -66,7 +66,7 @@ class ContentTypeService { const [err, result] = await safePromise(this.stackSDKInstance.contentType(id).delete()); if (err) { - errorHandler(id, ContentType, method, err); + errorHelper(err); this.base.dispatch(callsite, id, err, 'apiError'); throw err; } @@ -306,7 +306,7 @@ class ContentTypeService { } // Handling both the scenarios - if ((found === 0) || (against && (found === 1))) { + if (found === 0 || (against && found === 1)) { isValid = false; } diff --git a/packages/contentstack-migration/src/utils/error-helper.js b/packages/contentstack-migration/src/utils/error-helper.js index 47a748d183..649e16ef99 100644 --- a/packages/contentstack-migration/src/utils/error-helper.js +++ b/packages/contentstack-migration/src/utils/error-helper.js @@ -62,12 +62,19 @@ module.exports = (errors, filePath) => { after = removeSpecialCharacter(after.join('\n')); line = removeSpecialCharacter(line); errorLogs[file].lines = { before, line, after }; - + if (error.request) { + error.data = error.request?.data; + delete error.request; + } + if (error.message) { + delete error.message; + } const formattedCode = beforeLines + highlightedLine + afterLines; if (error.payload?.apiError) { errorLogs[file].apiError = true; errorLogs[file].errorCode = error.payload.apiError.errorCode; errorLogs[file].errors = error.payload.apiError.errors; + errorLogs[file].data = error.data; } if (error.message && !error.payload.apiError) { errorLogs[file].apiError = false;