mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
Handles error messages in start process cloud
Improves error handling by parsing the error message to get the error entry. If the message is not a valid JSON, uses the whole message string as an error message.
This commit is contained in:
@@ -458,7 +458,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
||||
},
|
||||
error: (err) => {
|
||||
this.errorMessageId = 'ADF_CLOUD_PROCESS_LIST.ADF_CLOUD_START_PROCESS.ERROR.START';
|
||||
this.unifyErrorResponse(err);
|
||||
this.unifyErrorResponse(err?.response?.body);
|
||||
this.error.emit(err);
|
||||
this.isProcessStarting = false;
|
||||
}
|
||||
@@ -486,9 +486,15 @@ export class StartProcessCloudComponent implements OnChanges, OnInit {
|
||||
|
||||
private unifyErrorResponse(err: any) {
|
||||
if (!err?.response?.body?.entry && err?.response?.body?.message) {
|
||||
err.response.body = {
|
||||
entry: JSON.parse(err.response.body.message)
|
||||
};
|
||||
try {
|
||||
const parsedMessage = JSON.parse(err.response.body.message);
|
||||
err.response.body.entry = parsedMessage;
|
||||
} catch (jsonError) {
|
||||
// If message is not valid JSON, use it as a string
|
||||
err.response.body.entry = {
|
||||
message: err.response.body.message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user