Removes unnecessary error handling method

Removes the `unifyErrorResponse` method as it's no longer needed.

Updates error handling logic to directly use the error message from the response body. This simplifies the error processing and avoids unnecessary parsing.
This commit is contained in:
APuschkin
2025-07-31 15:35:33 +02:00
parent 8da63a9795
commit 4446a6f524
2 changed files with 16 additions and 17 deletions

View File

@@ -877,7 +877,13 @@ describe('StartProcessCloudComponent', () => {
it('should throw error event when process cannot be started', async () => {
const errorSpy = spyOn(component.error, 'emit');
const error = { message: 'My error' };
const error = {
response: {
body: {
message: 'My error'
}
}
};
startProcessSpy = startProcessSpy.and.returnValue(throwError(error));
component.startProcess();
await fixture.whenStable();
@@ -888,14 +894,21 @@ describe('StartProcessCloudComponent', () => {
getDefinitionsSpy.and.returnValue(of(fakeProcessDefinitions));
const change = new SimpleChange('myApp', 'myApp1', true);
component.ngOnChanges({ appName: change });
startProcessSpy = startProcessSpy.and.returnValue(throwError({}));
const error = {
response: {
body: {
message: 'Process start failed'
}
}
};
startProcessSpy = startProcessSpy.and.returnValue(throwError(error));
component.startProcess();
fixture.detectChanges();
await fixture.whenStable();
const errorEl = fixture.nativeElement.querySelector('#error-message');
expect(errorEl.innerText.trim()).toBe('ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START');
expect(errorEl.innerText.trim()).toBe('Process start failed');
});
it('should emit start event when start select a process and add a name', (done) => {

View File

@@ -458,7 +458,6 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
},
error: (err) => {
this.errorMessageId = err?.response?.body?.message || 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START_PROCESS';
this.unifyErrorResponse(err);
this.error.emit(err);
this.isProcessStarting = false;
}
@@ -484,19 +483,6 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
}
}
private unifyErrorResponse(err: any) {
if (!err?.response?.body?.entry && err?.response?.body?.message) {
try {
err.response.body.entry = JSON.parse(err.response.body.message);
} catch (jsonError) {
console.warn('Failed to parse error message as JSON:', jsonError);
err.response.body.entry = {
message: err.response.body.message
};
}
}
}
cancelStartProcess() {
this.cancel.emit();
}