Commit 411b7b0d authored by maruel@chromium.org's avatar maruel@chromium.org

Print the exact path get_file.js is trying to write to when failing.

Clean up stray spaces.

TBR=iannucci@chromium.org
BUG=241769

Review URL: https://codereview.chromium.org/72783002

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@235145 0039d316-1c4b-4281-b951-d872f2087c98
parent 741cf9bb
......@@ -9,14 +9,14 @@ function Download(url, path, verbose) {
try {
xml_http = new ActiveXObject("MSXML2.ServerXMLHTTP");
} catch (e) {
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
": Cannot create Active-X object (" + e.description) + ").";
WScript.Quit(1);
}
try {
xml_http.open("GET", url, false);
} catch (e) {
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
": invalid URL.");
WScript.Quit(1);
}
......@@ -27,7 +27,7 @@ function Download(url, path, verbose) {
try {
xml_http.send(null);
if (xml_http.status != 200) {
WScript.StdOut.WriteLine("[-] HTTP " + xml_http.status + " " +
WScript.StdOut.WriteLine("[-] HTTP " + xml_http.status + " " +
xml_http.statusText);
WScript.Quit(1);
}
......@@ -45,7 +45,7 @@ function Download(url, path, verbose) {
}
}
} catch (e) {
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
": Cannot make HTTP request (" + e.description) + ")";
WScript.Quit(1);
}
......@@ -64,8 +64,9 @@ function Download(url, path, verbose) {
adodb_stream.SaveToFile(path, 2); // Save to our destination
adodb_stream.Close();
} catch(e) {
WScript.StdOut.WriteLine("[-] ADODB.Stream " + new Number(
e.number).toHex() + ": Cannot save file (" + e.description + ")");
WScript.StdOut.WriteLine(
"[-] ADODB.Stream " + new Number(e.number).toHex() +
": Cannot save file to " + path + ": " + e.description);
WScript.Quit(1);
}
if (typeof(file_size) != undefined) {
......@@ -83,13 +84,13 @@ function Download(url, path, verbose) {
// Utilities
Number.prototype.isInt = function NumberIsInt() {
return this % 1 == 0;
return this % 1 == 0;
};
Number.prototype.toBytes = function NumberToBytes() {
// Returns a "pretty" string representation of a number of bytes:
var units = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
var unit = "bytes";
var limit = 1;
var limit = 1;
while(this > limit * 1100 && units.length > 0) {
limit *= 1024;
unit = units.shift();
......@@ -99,11 +100,11 @@ Number.prototype.toBytes = function NumberToBytes() {
Number.prototype.toHex = function NumberToHex(length) {
if (arguments.length == 0) length = 1;
if (typeof(length) != "number" && !(length instanceof Number)) {
throw Exception("Length must be a positive integer larger than 0.",
throw Exception("Length must be a positive integer larger than 0.",
TypeError, 0);
}
if (length < 1 || !length.isInt()) {
throw Exception("Length must be a positive integer larger than 0.",
throw Exception("Length must be a positive integer larger than 0.",
"RangeError", 0);
}
var result = (this + (this < 0 ? 0x100000000 : 0)).toString(16);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment