Skip to content

Commit

Permalink
feat(core): Combine General Exception Messages with Custom and Kato M…
Browse files Browse the repository at this point in the history
…essages (#8330)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
Evan Sebastian and mergify[bot] committed Jun 24, 2020
1 parent aae2270 commit 587dcec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Expand Up @@ -41,7 +41,7 @@ describe('orchestratedItem transformer', () => {
expect(getMessage({ context: {} })).toBe(null);
});

it('returns general exception even if a kato task is present', () => {
it('returns combined exception if both kato and general exceptions are present', () => {
const stage = {
context: {
'kato.tasks': [
Expand All @@ -61,7 +61,7 @@ describe('orchestratedItem transformer', () => {
},
},
};
expect(getMessage(stage)).toBe('E1\n\nE2');
expect(getMessage(stage)).toBe('E1\n\nE2\n\nfailed!');
});

it('returns exception when it is in the last kato task', () => {
Expand Down
Expand Up @@ -51,11 +51,7 @@ export class OrchestratedItemTransformer {

Object.defineProperties(item, {
failureMessage: {
get: (): string =>
this.getCustomException(item) ||
this.getGeneralException(item) ||
this.getOrchestrationException(item) ||
null,
get: (): string => this.mergeExceptions(item),
},
isCompleted: {
get: (): boolean => ['SUCCEEDED', 'SKIPPED'].includes(item.status),
Expand Down Expand Up @@ -110,6 +106,18 @@ export class OrchestratedItemTransformer {
});
}

private static mergeExceptions(item: any): string | null {
const exceptions = [
this.getCustomException(item),
this.getGeneralException(item),
this.getOrchestrationException(item),
].filter(it => !!it);
if (exceptions.length === 0) {
return null;
}
return exceptions.join('\n\n');
}

private static getOrchestrationException(task: ITask): string {
const katoTasks: any[] = task.getValueFor('kato.tasks');
if (katoTasks && katoTasks.length) {
Expand Down

0 comments on commit 587dcec

Please sign in to comment.