Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: remoting/webapp/crd/js/error.js

Issue 1065733004: Added partial unit tests for host_controller.js. More to come. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@hdf-unittest
Patch Set: for review Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 /** 10 /**
(...skipping 25 matching lines...) Expand all
36 }; 36 };
37 37
38 /** 38 /**
39 * @return {remoting.Error.Tag} The tag used to create this Error. 39 * @return {remoting.Error.Tag} The tag used to create this Error.
40 */ 40 */
41 remoting.Error.prototype.getTag = function() { 41 remoting.Error.prototype.getTag = function() {
42 return this.tag_; 42 return this.tag_;
43 }; 43 };
44 44
45 /** 45 /**
46 * @return {?string} The detail string passed to the constructor, if any.
47 */
48 remoting.Error.prototype.getDetail = function() {
49 return this.detail_;
50 };
51
52 /**
46 * Checks the type of an error. 53 * Checks the type of an error.
47 * @param {remoting.Error.Tag} tag 54 * @param {remoting.Error.Tag} tag
48 * @param {...remoting.Error.Tag} var_args 55 * @param {...remoting.Error.Tag} var_args
49 * @return {boolean} True if this object has one of the specified tags. 56 * @return {boolean} True if this object has one of the specified tags.
50 */ 57 */
51 remoting.Error.prototype.hasTag = function(tag, var_args) { 58 remoting.Error.prototype.hasTag = function(tag, var_args) {
52 var thisTag = this.tag_; 59 var thisTag = this.tag_;
53 return Array.prototype.some.call( 60 return Array.prototype.some.call(
54 arguments, 61 arguments,
55 function(/** remoting.Error.Tag */ tag) { 62 function(/** remoting.Error.Tag */ tag) {
(...skipping 12 matching lines...) Expand all
68 /** 75 /**
69 * Convenience method for creating the second most common error type. 76 * Convenience method for creating the second most common error type.
70 * @return {!remoting.Error} 77 * @return {!remoting.Error}
71 */ 78 */
72 remoting.Error.none = function() { 79 remoting.Error.none = function() {
73 return new remoting.Error(remoting.Error.Tag.NONE); 80 return new remoting.Error(remoting.Error.Tag.NONE);
74 }; 81 };
75 82
76 /** 83 /**
77 * Convenience method for creating the most common error type. 84 * Convenience method for creating the most common error type.
85 * @param {string=} opt_detail
78 * @return {!remoting.Error} 86 * @return {!remoting.Error}
79 */ 87 */
80 remoting.Error.unexpected = function() { 88 remoting.Error.unexpected = function(opt_detail) {
81 return new remoting.Error(remoting.Error.Tag.UNEXPECTED); 89 return new remoting.Error(remoting.Error.Tag.UNEXPECTED, opt_detail);
82 }; 90 };
83 91
84 /** 92 /**
85 * @enum {string} All error messages from messages.json 93 * @enum {string} All error messages from messages.json
86 */ 94 */
87 remoting.Error.Tag = { 95 remoting.Error.Tag = {
88 NONE: '', 96 NONE: '',
89 97
90 // Used to signify that an operation was cancelled by the user. This should 98 // Used to signify that an operation was cancelled by the user. This should
91 // not normally cause the error text to be shown to the user, so the 99 // not normally cause the error text to be shown to the user, so the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 remoting.Error.handler = function(onError) { 161 remoting.Error.handler = function(onError) {
154 return function(/** * */ error) { 162 return function(/** * */ error) {
155 if (error instanceof remoting.Error) { 163 if (error instanceof remoting.Error) {
156 onError(/** @type {!remoting.Error} */ (error)); 164 onError(/** @type {!remoting.Error} */ (error));
157 } else { 165 } else {
158 console.error('Unexpected error:', error); 166 console.error('Unexpected error:', error);
159 onError(remoting.Error.unexpected()); 167 onError(remoting.Error.unexpected());
160 } 168 }
161 }; 169 };
162 }; 170 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698