www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 3fb2dfe9ac1f926f30924841002a0bb41d6b7576
parent 0d008b4704ccf1e09e287a12311a932a23f5436e
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu,  2 Jun 2016 03:34:56 -0400

Log error from NetUtil.asyncFetch in Zotero.File.putContentsAsync()

Diffstat:
Mchrome/content/zotero/xpcom/file.js | 75+++++++++++++++++++++++++++++++++++++++++----------------------------------
1 file changed, 41 insertions(+), 34 deletions(-)

diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js @@ -221,47 +221,54 @@ Zotero.File = new function(){ }; var deferred = Zotero.Promise.defer(); - NetUtil.asyncFetch(source, function(inputStream, status) { - if (!Components.isSuccessCode(status)) { - deferred.reject(new Components.Exception("File read operation failed", status)); - return; - } - - try { - try { - var bytesToFetch = inputStream.available(); - } - catch (e) { - // The stream is closed automatically when end-of-file is reached, - // so this throws for empty files - if (e.name == "NS_BASE_STREAM_CLOSED") { - deferred.resolve(""); - } - } - - if (maxLength && maxLength < bytesToFetch) { - bytesToFetch = maxLength; - } - - if (bytesToFetch == 0) { - deferred.resolve(""); + try { + NetUtil.asyncFetch(source, function(inputStream, status) { + if (!Components.isSuccessCode(status)) { + deferred.reject(new Components.Exception("File read operation failed", status)); return; } - deferred.resolve( - NetUtil.readInputStreamToString( + try { + try { + var bytesToFetch = inputStream.available(); + } + catch (e) { + // The stream is closed automatically when end-of-file is reached, + // so this throws for empty files + if (e.name == "NS_BASE_STREAM_CLOSED") { + Zotero.debug("RESOLVING2"); + deferred.resolve(""); + } + deferred.reject(e); + } + + if (maxLength && maxLength < bytesToFetch) { + bytesToFetch = maxLength; + } + + if (bytesToFetch == 0) { + deferred.resolve(""); + return; + } + + deferred.resolve(NetUtil.readInputStreamToString( inputStream, bytesToFetch, options - ) - ); - } - catch (e) { - deferred.reject(e); - } - }); + )); + } + catch (e) { + deferred.reject(e); + } + }); + } + catch(e) { + // Make sure this get logged correctly + Zotero.logError(e); + throw e; + } return deferred.promise; - }; + } /**