From 411b7b0dbed47ab603108e3dbc47caffd970b240 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Thu, 14 Nov 2013 15:38:04 +0000 Subject: [PATCH] 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 --- bootstrap/win/get_file.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bootstrap/win/get_file.js b/bootstrap/win/get_file.js index ef0860135..2561fb3c3 100644 --- a/bootstrap/win/get_file.js +++ b/bootstrap/win/get_file.js @@ -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);