From 84a9b38811bf89b57cb111c59e5e42a14034a13a Mon Sep 17 00:00:00 2001 From: Alexei Barantsev Date: Mon, 15 Jun 2015 19:39:27 +0300 Subject: [PATCH] firefox: Moving WebDriverError from utils.js to error.js --- javascript/firefox-driver/BUCK | 1 + javascript/firefox-driver/build.desc | 3 ++ javascript/firefox-driver/js/error.js | 58 +++++++++++++++++++++++++++ javascript/firefox-driver/js/utils.js | 57 -------------------------- 4 files changed, 62 insertions(+), 57 deletions(-) diff --git a/javascript/firefox-driver/BUCK b/javascript/firefox-driver/BUCK index e84f5a4366037..603b652ac455d 100644 --- a/javascript/firefox-driver/BUCK +++ b/javascript/firefox-driver/BUCK @@ -369,6 +369,7 @@ js_library(name = 'files', 'js/files.js', ], deps = [ + ':error', '//third_party/closure:closure', ], ) diff --git a/javascript/firefox-driver/build.desc b/javascript/firefox-driver/build.desc index 7eb8a58356391..567deff4a34a8 100644 --- a/javascript/firefox-driver/build.desc +++ b/javascript/firefox-driver/build.desc @@ -276,6 +276,9 @@ js_library(name = "events", js_library(name = "files", srcs = [ "js/files.js", + ], + deps = [ + ":error", ]) js_library(name = "logging", diff --git a/javascript/firefox-driver/js/error.js b/javascript/firefox-driver/js/error.js index 3da3c35cea889..32ab6eadc3971 100644 --- a/javascript/firefox-driver/js/error.js +++ b/javascript/firefox-driver/js/error.js @@ -16,6 +16,64 @@ // under the License. goog.provide('fxdriver.error'); +goog.provide('WebDriverError'); + + +/** + * A WebDriver error. + * @param {!number} code The error code. + * @param {!string|Error} messageOrError The error message, or another Error to + * propagate. + * @param {!Object=} additional Additional fields bearing useful information. + * @constructor + */ +WebDriverError = function(code, messageOrError, additional) { + var message; + var stack; + if (messageOrError instanceof Error) { + message = messageOrError.message; + stack = messageOrError.stack; + } else { + message = messageOrError.toString(); + stack = Error(message).stack.split('\n'); + stack.shift(); + stack = stack.join('\n'); + } + + this.additionalFields = []; + + if (!!additional) { + for (var field in additional) { + this.additionalFields.push(field); + this[field] = additional[field]; + } + } + + /** + * This error's status code. + * @type {!number} + */ + this.code = code; + + /** + * This error's message. + * @type {string} + */ + this.message = message; + + /** + * Captures a stack trace for when this error was thrown. + * @type {string} + */ + this.stack = stack; + + /** + * Used to identify this class since instanceof will not work across + * component boundaries. + * @type {!boolean} + */ + this.isWebDriverError = true; +}; /** diff --git a/javascript/firefox-driver/js/utils.js b/javascript/firefox-driver/js/utils.js index 39c1a0eccac74..1860e1c4165e6 100644 --- a/javascript/firefox-driver/js/utils.js +++ b/javascript/firefox-driver/js/utils.js @@ -16,7 +16,6 @@ // under the License. goog.provide('Utils'); -goog.provide('WebDriverError'); goog.require('WebLoadingListener'); goog.require('bot.ErrorCode'); @@ -32,62 +31,6 @@ goog.require('goog.string'); goog.require('goog.style'); -/** - * A WebDriver error. - * @param {!number} code The error code. - * @param {!string|Error} messageOrError The error message, or another Error to - * propagate. - * @param {!Object=} additional Additional fields bearing useful information. - * @constructor - */ -WebDriverError = function(code, messageOrError, additional) { - var message; - var stack; - if (messageOrError instanceof Error) { - message = messageOrError.message; - stack = messageOrError.stack; - } else { - message = messageOrError.toString(); - stack = Error(message).stack.split('\n'); - stack.shift(); - stack = stack.join('\n'); - } - - this.additionalFields = []; - - if (!!additional) { - for (var field in additional) { - this.additionalFields.push(field); - this[field] = additional[field]; - } - } - - /** - * This error's status code. - * @type {!number} - */ - this.code = code; - - /** - * This error's message. - * @type {string} - */ - this.message = message; - - /** - * Captures a stack trace for when this error was thrown. - * @type {string} - */ - this.stack = stack; - - /** - * Used to identify this class since instanceof will not work across - * component boundaries. - * @type {!boolean} - */ - this.isWebDriverError = true; -}; - function notifyOfCloseWindow(windowId) { windowId = windowId || 0; if (Utils.useNativeEvents()) {