12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Dashboard
- *| (C) Copyright IBM Corp. 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define([], function () {
- 'use strict';
- /**
- *we could pass options for initialization
- *@constructor
- */
- var AjaxHelper = function AjaxHelper() {
- return {
- showAjaxServiceErrorMessage: function showAjaxServiceErrorMessage(dashboardApi, jqXHR) {
- var messages = '';
- if (jqXHR) {
- var responseJSON = jqXHR.responseJSON;
- if (responseJSON) {
- if (responseJSON.messages) {
- messages = jqXHR.responseJSON.messages.join('\n');
- } else if (responseJSON.cause) {
- try {
- var cause = JSON.parse(responseJSON.cause);
- if (cause.messages) {
- messages = cause.messages.join('\n');
- }
- } catch (e) {
- //if we get here, 'cause' is not a json object
- messages = responseJSON.cause;
- }
- }
- } else {
- messages = jqXHR.responseText;
- }
- }
- if (messages && messages.length > 0) {
- // RTC189248 - Don't show empty error messages!
- dashboardApi.showErrorMessage(messages, 'Error');
- }
- }
- };
- };
- return new AjaxHelper();
- });
- //# sourceMappingURL=AjaxHelper.js.map
|