Skip to content

Commit

Permalink
Replace non-standard 'catch (ex if cond)'
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkf committed Nov 22, 2021
1 parent ac8359c commit 7ee407d
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 45 deletions.
12 changes: 7 additions & 5 deletions chrome.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ content dta-public chrome/public/ contentaccessible
skin dta-public classic/1.0 chrome/public/

## aux packages ##
content dta-tests tests/
content dta-modules modules/

## additional locales
Expand All @@ -33,14 +34,15 @@ locale dta zh-CN chrome/locale/zh-CN/
locale dta zh-TW chrome/locale/zh-TW/

## platform package ##
content dta-platform chrome/content/ platform
skin dta-platform classic/1.0 chrome/skin/
content dta-platform chrome/content/unix/
content dta-platform chrome/content/mac/ os=Darwin
content dta-platform chrome/content/win/ os=WINNT
skin dta-platform classic/1.0 chrome/skin/unix/
skin dta-platform classic/1.0 chrome/skin/mac/ os=Darwin
skin dta-platform classic/1.0 chrome/skin/win/ os=WINNT

override chrome://dta/content/dta/manager.xul chrome://dta/content/dta/manager-aero.xul os=WINNT osversion=6
override chrome://dta/content/dta/manager.xul chrome://dta/content/dta/manager-newer.xul os=WINNT osversion>6
override chrome://dta/content/dta/manager.xul chrome://dta/content/dta/manager-aero.xul os=WINNT osversion=6.1
override chrome://dta-platform/skin/common.css chrome://dta-platform/skin/common-aero.css os=WINNT osversion>=6
override chrome://dta/skin/manager/netstatus.png chrome://dta-platform/skin/netstatus-aero.png os=WINNT osversion>=6

# Hack to prevent .Net Framework Assistant from messing up the browser, courtesy of AdBlock Plus
override chrome://dotnetassistant/content/bootstrap.xul data:text/xml,<nada/>
28 changes: 22 additions & 6 deletions chrome/content/dta/manager/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2071,8 +2071,12 @@ QueueItem.prototype = {
try {
yield OS.File.remove(file.path);
}
catch (ex if ex.becauseNoSuchFile) {
// no op
catch (ex) {
if (!(ex.becauseNoSuchFile)) {
throw ex;
} /* else {
// no op
} */
}
}

Expand Down Expand Up @@ -2438,17 +2442,25 @@ QueueItem.prototype = {
try {
yield Utils.makeDir(file.parent, Prefs.dirPermissions);
}
catch (ex if ex.becauseExists) {
catch (ex) {
if (!(ex.becauseExists)) {
throw ex;
} /* else {
// no op
} */
}
try {
if (this.totalSize === (yield OS.File.stat(file.path)).size) {
log(LOG_INFO, "pa: already allocated");
return;
}
}
catch (ex if ex.becauseNoSuchFile) {
catch (ex) {
if (!(ex.becauseNoSuchFile)) {
throw ex;
} /* else {
// no op
} */
}
let pa = Preallocator.prealloc(
file,
Expand Down Expand Up @@ -2486,8 +2498,12 @@ QueueItem.prototype = {
Task.spawn(function*() {
try {
yield OS.File.remove(tmpFile.path);
} catch (ex if ex.becauseNoSuchFile) {
// no op
} catch (ex) {
if (!(ex.becauseNoSuchFile)) {
throw ex;
} /* else {
// no op
} */
}
}).then(null, function(ex) {
log(LOG_ERROR, "failed to remove tmpfile: " + tmpFile.path, ex);
Expand Down
4 changes: 2 additions & 2 deletions install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<em:id>{DDC359D1-844A-42a7-9AA1-88A850A938A8}</em:id>
<em:name>DownThemAll!</em:name>
<em:description>The mass downloader for Firefox.</em:description>
<em:version>3.0.9.1</em:version>
<em:version>3.0.9.2</em:version>
<em:bootstrap>true</em:bootstrap>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:type>2</em:type>
Expand Down Expand Up @@ -35,7 +35,7 @@
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.40</em:minVersion>
<em:maxVersion>2.53.9.*</em:maxVersion>
<em:maxVersion>2.53.10.*</em:maxVersion>
</Description>
</em:targetApplication>

Expand Down
10 changes: 7 additions & 3 deletions modules/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ function createFactory(direct, cls) {
try {
Cm.registerFactory(i.classID, i.classDescription, i.contractID, this);
}
catch (ex if ex.result === Cr.NS_ERROR_FACTORY_EXISTS) {
defer(this.register.bind(this));
return;
catch (ex) {
if (ex.result === Cr.NS_ERROR_FACTORY_EXISTS) {
defer(this.register.bind(this));
return;
} else {
throw ex;
}
}

if (i.xpcom_categories) {
Expand Down
24 changes: 18 additions & 6 deletions modules/manager/chunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,12 @@ Chunk.prototype = {
try {
yield makeDir(file.parent, Prefs.dirPermissions, true);
}
catch (ex if ex.becauseExists) {
// no op
catch (ex) {
if (!(ex.becauseExists)) {
throw ex;
} /* else {
// no op
} */
}
let outStream = this._fileOutputStream = new Instances.FileOutputStream(
file,
Expand Down Expand Up @@ -422,8 +426,12 @@ Chunk.prototype = {
try {
written = this._outStream.writeFrom(aInputStream, bytes);
}
catch (ex if ex.result == Cr.NS_BASE_STREAM_WOULD_BLOCK || ex == Cr.NS_BASE_STREAM_WOULD_BLOCK) {
// aka still nothing written
catch (ex) {
if (!(ex.result == Cr.NS_BASE_STREAM_WOULD_BLOCK || ex == Cr.NS_BASE_STREAM_WOULD_BLOCK)) {
throw ex;
} /* else {
// aka still nothing written
} */
}
/* jshint +W116 */
let remain = bytes - written;
Expand Down Expand Up @@ -474,8 +482,12 @@ Chunk.prototype = {
try {
written = this._outStream.writeFrom(instream, avail);
}
catch (ex if ex.result == Cr.NS_BASE_STREAM_WOULD_BLOCK || ex == Cr.NS_BASE_STREAM_WOULD_BLOCK) {
// nothing written
catch (ex) {
if (!(ex.result == Cr.NS_BASE_STREAM_WOULD_BLOCK || ex == Cr.NS_BASE_STREAM_WOULD_BLOCK)) {
throw ex;
} /* else {
// nothing written
} */
}
/* jshint +W116 */
avail -= written;
Expand Down
10 changes: 7 additions & 3 deletions modules/manager/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,13 @@ Connection.prototype = {
this.discard(aInputStream, aCount - written);
}
}
catch (ex if (ex !== NS_ERROR_BINDING_ABORTED && ex.result !== NS_ERROR_BINDING_ABORTED)) {
log(LOG_ERROR, 'onDataAvailable', ex);
this.writeFailed(ex);
catch (ex) {
if (ex !== NS_ERROR_BINDING_ABORTED && ex.result !== NS_ERROR_BINDING_ABORTED) {
log(LOG_ERROR, 'onDataAvailable', ex);
this.writeFailed(ex);
} else {
throw ex;
}
}
},

Expand Down
20 changes: 13 additions & 7 deletions modules/support/alertservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,19 @@ exports.show = function alertservice_show(title, msg, callback, icon) {
"@downthemall.net/" + Date.now().toString()
);
}
catch (ex if ex.result === Cr.NS_ERROR_NOT_IMPLEMENTED) {
log(LOG_DEBUG, "alertsservice not available after all", ex);
}
catch (ex if ex.result === Cr.NS_ERROR_NOT_AVAILABLE) {
log(LOG_DEBUG, "alertsservice (temporarily) not available", ex);
}
catch (ex) {
log(LOG_ERROR, "alertsservice unexpectedly failed", ex);
switch (ex.result) {
case Cr.NS_ERROR_NOT_IMPLEMENTED: {
log(LOG_DEBUG, "alertsservice not available after all", ex);
break;
}
case Cr.NS_ERROR_NOT_AVAILABLE: {
log(LOG_DEBUG, "alertsservice (temporarily) not available", ex);
break;
}
default: {
log(LOG_ERROR, "alertsservice unexpectedly failed", ex);
}
}
}
};
8 changes: 6 additions & 2 deletions modules/support/filtermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,12 @@ FilterManagerImpl.prototype = {
try {
yield OS.File.makeDir(this._file.parent.path, {unixMode: 0o775, ignoreExisting: true});
}
catch (ex if ex.becauseExists) {
// no op;
catch (ex) {
if (!(ex.becauseExists)) {
throw ex;
} /* else {
// no op;
} */
}
yield this._saver.saveChanges();
}
Expand Down
21 changes: 10 additions & 11 deletions modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,14 @@ exports.makeDir = function*(dir, perms, force) {
yield OS.File.makeDir(dir.path, {unixMode: perms});
makeDirCache.set(dir.path, perms);
}
catch (ex if ex.becauseExists) {
// no op
}
catch (ex if ex.becauseNoSuchFile) {
yield exports.makeDir(dir.parent, perms);
yield exports.makeDir(dir, perms);
}
catch (ex if ex.winLastError === 3) {
yield exports.makeDir(dir.parent, perms);
yield exports.makeDir(dir, perms);
}
catch (ex) {
if (ex.becauseExists) {
// no op
} else if (ex.becauseNoSuchFile || (ex.winLastError === 3)) {
yield exports.makeDir(dir.parent, perms);
yield exports.makeDir(dir, perms);
} else {
throw ex;
}
}
};

0 comments on commit 7ee407d

Please sign in to comment.