in the following post is probably the answer to my question, but I don't see it: Stick with generic ErrorHandler.js while allowing custom errormessage handling per request and not have double message boxes
I am extending a Fiori Standard App (MyProfile to be concrete) and so everything works fine. Now the customer wants to show special error messages depending on the technical message sent from the Gateway. So I tried to extend the ErrorHandler in the Component.js:
jQuery.sap.declare("com.company.hcm.fab.myprofile.ext.Component");
jQuery.sap.require("com.company.hcm.fab.myprofile.ext.controller.ErrorHandler");
sap.ui.component.load({
name: "hcm.fab.myprofile",
url: "/sap/bc/ui5_ui5/sap/hcmfab_prfl_mon"
});
this.hcm.fab.myprofile.Component.extend("com.company.hcm.fab.myprofile.ext.Component", {
metadata: {
manifest: "json"
},
init: function() {
hcm.fab.myprofile.Component.prototype.init.apply(this, arguments);
this._oErrorHandler = new com.company.hcm.fab.myprofile.ext.controller.ErrorHandler(this);
}
});
And I extended the ErrorHandler.js in the way that I understood from the shown post:
sap.ui.define([
"hcm/fab/myprofile/controller/ErrorHandler",
"sap/m/MessageBox"
], function(ErrorHandler, MessageBox) {
"use strict";
return ErrorHandler.extend("com.company.hcm.fab.myprofile.ext.controller.ErrorHandler", {
constructor: function (oComponent) {
this._oResourceBundle = oComponent.getModel("i18n").getResourceBundle();
this._oComponent = oComponent;
this._oModel = oComponent.getModel();
this._sErrorText = this._oResourceBundle.getText("errorTitle");
this._oModel.attachRequestFailed(this._requestFailedHandler, this);
},
_requestFailedHandler: function(oEvent) {
var oParameters = oEvent.getParameters();
console.log("now?", oResponse);
this._showServiceError(oParameters.response);
}
});
});
Never the less I don't only see my message, but also still see the message from the ErrorHandler in the standard app. Does anyone have an idea?
Best regards Marco
Update To clarify my ideas: In the original app, which I'm extending, the ErrorHandler is initialized in the init-Method. So if I get it right, I have to either completely rewrite/overwrite the init-Method, or I find a way to detach the original Events and then I can extend or rewrite the ErrorHandler. I prefer the later option, because I not only have to extend the ErrorHandler in this standard fiori app, but in six others as well. And always rewriting the init-method feels worse than always rewriting the ErrorHandler.