Skip to content

Commit

Permalink
firefox: Moving WebDriverError from utils.js to error.js
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Jun 15, 2015
1 parent 33f86ba commit 84a9b38
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 57 deletions.
1 change: 1 addition & 0 deletions javascript/firefox-driver/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ js_library(name = 'files',
'js/files.js',
],
deps = [
':error',
'//third_party/closure:closure',
],
)
Expand Down
3 changes: 3 additions & 0 deletions javascript/firefox-driver/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ js_library(name = "events",
js_library(name = "files",
srcs = [
"js/files.js",
],
deps = [
":error",
])

js_library(name = "logging",
Expand Down
58 changes: 58 additions & 0 deletions javascript/firefox-driver/js/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


/**
Expand Down
57 changes: 0 additions & 57 deletions javascript/firefox-driver/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// under the License.

goog.provide('Utils');
goog.provide('WebDriverError');

goog.require('WebLoadingListener');
goog.require('bot.ErrorCode');
Expand All @@ -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()) {
Expand Down

0 comments on commit 84a9b38

Please sign in to comment.