Error handling without JavaScipt Code
-
JohannesHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)Has successfully completed the online course Advanced (310)Has successfully completed the online course Advanced (320)9 months ago #43969
Are there ways to display this error handling as shown in the code via Simplifier UI applications or is this code really required for this? Error
For Example…
try {
var pages = sap.ui.getCore().byId(“Application”).getPages();
for (var i = 0; i < pages.length; i++) {
pages[i].getController()._handleRequestError = function(showBusyIndicator, failCallback, ajaxSetup, errorData) {
if (showBusyIndicator) {
sap.ui.core.BusyIndicator.hide();
}
var status = errorData.status;
if (status === 401) {
this.setItemValue(“Dialogs”, “Dialog_ServerError”, “dialogOpened”, true);
} else if (status === 504) {
this.setItemValue(“Dialogs”, “Dialog_ServerError”, “dialogOpened”, true);
} else {
this.setItemValue(“Dialogs”, “Dialog_ServerError”, “dialogOpened”, true);
}}
}
} catch (e) {}
Thanks
Armin WinklerHas successfully completed the online course IntroductionHas successfully completed the online course Intermediate (200)Has successfully completed the online course Advanced (300)Has successfully completed the online course Basics (100)8 months ago #44235::Hi Johannes,
as already discussed in a previous enabling session, it heavily depends on your exact use case whether you want to globally overwrite the default error handling within your Simplifier application.
Usually, if a server request made by either a connector (call) or a business object function fails and there’s no error mapping made in the Process Designer, then a generic error popup comes up that includes the error message returned by the server. Apparently, in your script you tried to display an own error dialog instead and defined a case differentiation for a list of certain HTTP status codes to display specific error messages in that dialog. However, it seems like in the end, you always open one and the same dialog, so the implementation might be unfinished as it is.
Generally, we do not recommend overwriting standard JavaScript code as generated on deploying your Simplifier application. Instead, you can add your own error handling to failed server requests by connecting activities like UI Actions to the error ports of your shapes in the Process Designer. To make use of reusability and a consistent look and feel of an error message display, you could always link the error port of your server request activities (i.e. connector calls and server-side business object functions) to a custom event publishing. The custom event can then be subscribed to in another central Process Designer story and only open a certain popup element like a dialog or possibly a MessageToast. You then only have to ensure that you map a proper and fitting message to the related widget properties of the popup element, so that your app users understand the context of the error that occured.
So in short: No, this JavaScript code is not needed, but you can provide error handling in your app processes using the error node of the respective low code activities.
Kind regards,
Armin
You must be logged in to reply to this topic.