mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-526: Add convenience callback for displaying modal notifications strictly for REST errors, while logging all other promise rejections.
This commit is contained in:
@@ -21,4 +21,7 @@
|
||||
* The module for code relating to communication with the REST API of the
|
||||
* Guacamole web application.
|
||||
*/
|
||||
angular.module('rest', ['auth']);
|
||||
angular.module('rest', [
|
||||
'auth',
|
||||
'notification'
|
||||
]);
|
||||
|
@@ -27,6 +27,7 @@ angular.module('rest').factory('requestService', ['$injector',
|
||||
// Required services
|
||||
var $http = $injector.get('$http');
|
||||
var $log = $injector.get('$log');
|
||||
var guacNotification = $injector.get('guacNotification');
|
||||
|
||||
// Required types
|
||||
var Error = $injector.get('Error');
|
||||
@@ -115,6 +116,19 @@ angular.module('rest').factory('requestService', ['$injector',
|
||||
$log.warn(error.type, error.message || error.translatableMessage);
|
||||
});
|
||||
|
||||
/**
|
||||
* Promise error callback which displays a modal notification for all
|
||||
* rejections due to REST errors. The message displayed to the user within
|
||||
* the notification is provided by the contents of the @link{Error} object
|
||||
* within the REST response. All other rejections, such as those due to
|
||||
* JavaScript errors, are logged to the browser console without displaying
|
||||
* any notification.
|
||||
*
|
||||
* @constant
|
||||
* @type Function
|
||||
*/
|
||||
service.SHOW_NOTIFICATION = service.createErrorCallback(guacNotification.showRequestError);
|
||||
|
||||
return service;
|
||||
|
||||
}]);
|
||||
|
Reference in New Issue
Block a user