Skip to content

Commit 7afbef3

Browse files
authored
Merge pull request #356 from sf-kishore-kurri/u/kkurri/W-19180686
feat: @W-19180686: Fix for error message unification both assess/migrate
2 parents d128ab9 + 85ab4f5 commit 7afbef3

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

messages/assess.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@
114114
"errorParsingData": "Error while parsing data for template",
115115
"errorGeneratingHTML": "Error while generating HTML from template for %s with properties %s",
116116
"unexpectedError": "Unexpected Assessment error",
117-
"errorEvaluatingExpression": "Error evaluating expression: %s, %s"
117+
"errorEvaluatingExpression": "Error evaluating expression: %s, %s",
118+
"invalidTypeAssessErrorMessage": "We couldn't assess your Omnistudio components in the %s namespace. Select the correct namespace and try again"
118119
}

messages/migrate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@
114114
"labelStatusFailed": "Failed",
115115
"labelStatusComplete": "Complete",
116116
"migrationConsentNotGiven": "Couldn't confirm whether assessment errors are resolved",
117-
"migrationConsentMessage": "Ensure that all items in the assessment report are marked as Green before proceeding with the migration. Do you want to proceed?"
117+
"migrationConsentMessage": "Ensure that all items in the assessment report are marked as Green before proceeding with the migration. Do you want to proceed?",
118+
"invalidTypeMigrateErrorMessage": "We couldn't migrate your Omnistudio components in the %s namespace. Select the correct namespace and try again"
118119
}

src/commands/omnistudio/migration/assess.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import OmniStudioBaseCommand from '../../basecommand';
55
import { AssessmentInfo } from '../../../utils/interfaces';
66
import { AssessmentReporter } from '../../../utils/resultsbuilder/assessmentReporter';
77
import { OmniScriptExportType, OmniScriptMigrationTool } from '../../../migration/omniscript';
8+
import { InvalidEntityTypeError } from '../../../migration/interfaces';
89
import { CardMigrationTool } from '../../../migration/flexcard';
910
import { DataRaptorMigrationTool } from '../../../migration/dataraptor';
1011
import { DebugTimer } from '../../../utils';
@@ -116,9 +117,13 @@ export default class Assess extends OmniStudioBaseCommand {
116117
try {
117118
// Assess OmniStudio components
118119
await this.assessOmniStudioComponents(assesmentInfo, assessOnly, namespace, conn, allVersions);
119-
} catch (error) {
120-
Logger.error(`Cannot assess OmniStudio components within ${namespace}`);
121-
process.exit(1);
120+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
121+
} catch (ex: any) {
122+
if (ex instanceof InvalidEntityTypeError) {
123+
Logger.error(`${messages.getMessage('invalidTypeAssessErrorMessage', [namespace])}`);
124+
process.exit(1);
125+
}
126+
Logger.error('Error assessing object', ex);
122127
}
123128

124129
let objectsToProcess: string[];

src/commands/omnistudio/migration/migrate.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export default class Migrate extends OmniStudioBaseCommand {
169169
const allTruncateComplete = objectMigrationResults.length === 0;
170170

171171
if (allTruncateComplete) {
172-
objectMigrationResults = await this.migrateObjects(migrationObjects, debugTimer);
172+
objectMigrationResults = await this.migrateObjects(migrationObjects, debugTimer, namespace);
173173
}
174174

175175
const omnistudioRelatedObjectsMigration = new OmnistudioRelatedObjectMigrationFacade(
@@ -274,7 +274,11 @@ export default class Migrate extends OmniStudioBaseCommand {
274274
return objectMigrationResults;
275275
}
276276

277-
private async migrateObjects(migrationObjects: MigrationTool[], debugTimer: DebugTimer): Promise<MigratedObject[]> {
277+
private async migrateObjects(
278+
migrationObjects: MigrationTool[],
279+
debugTimer: DebugTimer,
280+
namespace: string
281+
): Promise<MigratedObject[]> {
278282
let objectMigrationResults: MigratedObject[] = [];
279283
for (const cls of migrationObjects.reverse()) {
280284
try {
@@ -292,7 +296,7 @@ export default class Migrate extends OmniStudioBaseCommand {
292296
);
293297
} catch (ex: any) {
294298
if (ex instanceof InvalidEntityTypeError) {
295-
Logger.error(ex.message);
299+
Logger.error(messages.getMessage('invalidTypeMigrateErrorMessage', [namespace]));
296300
process.exit(1);
297301
}
298302
Logger.error('Error migrating object', ex);

0 commit comments

Comments
 (0)