You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2018/04/29 20:58:53 UTC
[11/19] guacamole-client git commit: GUACAMOLE-526: Add convenience
callbacks for ignoring or (quietly) warning of REST errors.
GUACAMOLE-526: Add convenience callbacks for ignoring or (quietly) warning of REST errors.
Project: http://git-wip-us.apache.org/repos/asf/guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-client/commit/cc6ade49
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-client/tree/cc6ade49
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-client/diff/cc6ade49
Branch: refs/heads/master
Commit: cc6ade49171627cd89075ab91cde9317196989c2
Parents: c30b7b0
Author: Michael Jumper <mj...@apache.org>
Authored: Thu Apr 26 21:19:22 2018 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Thu Apr 26 21:19:22 2018 -0700
----------------------------------------------------------------------
.../webapp/app/rest/services/requestService.js | 26 +++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/guacamole-client/blob/cc6ade49/guacamole/src/main/webapp/app/rest/services/requestService.js
----------------------------------------------------------------------
diff --git a/guacamole/src/main/webapp/app/rest/services/requestService.js b/guacamole/src/main/webapp/app/rest/services/requestService.js
index b2f709b..9aef124 100644
--- a/guacamole/src/main/webapp/app/rest/services/requestService.js
+++ b/guacamole/src/main/webapp/app/rest/services/requestService.js
@@ -91,6 +91,30 @@ angular.module('rest').factory('requestService', ['$injector',
});
};
- return service;
+ /**
+ * Promise error callback which ignores all rejections due to REST errors,
+ * but logs all other rejections, such as those due to JavaScript errors.
+ * This callback should be used in favor of angular.noop in cases where
+ * a REST response is being handled but REST errors should be ignored.
+ *
+ * @constant
+ * @type Function
+ */
+ service.IGNORE = service.createErrorCallback(angular.noop);
+
+ /**
+ * Promise error callback which logs all rejections due to REST errors as
+ * warnings to the browser console, and logs all other rejections as
+ * errors. This callback should be used in favor of angular.noop or
+ * @link{IGNORE} if REST errors are simply not expected.
+ *
+ * @constant
+ * @type Function
+ */
+ service.WARN = service.createErrorCallback(function warnRequestFailed(error) {
+ $log.warn(error.type, error.message || error.translatableMessage);
+ });
+
+ return service;
}]);