[gnome-documents] application: Tie the catch block more tightly to the failure site
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] application: Tie the catch block more tightly to the failure site
- Date: Wed, 6 Jun 2018 17:43:36 +0000 (UTC)
commit f8240ce1c981dfd3ff9a3cdc4ae9bef05bc1be7c
Author: Debarshi Ray <debarshir gnome org>
Date: Fri Dec 8 17:13:52 2017 +0100
application: Tie the catch block more tightly to the failure site
Having a lot of code inside a try statement makes it harder to follow
the error handling logic. The catch statements are far away from the
code that can throw an exception, so it is difficult to match them
together. Let's reduce the size of the try blocks by only using them
for fallible operations.
https://bugzilla.gnome.org/show_bug.cgi?id=791518
src/application.js | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 3de397ac..8d168588 100644
--- a/src/application.js
+++ b/src/application.js
@@ -153,19 +153,21 @@ var Application = new Lang.Class({
function(object, res) {
try {
let info = object.query_info_finish(res);
- this.gettingStartedLocation = file.get_parent();
-
- manager.index_file_async(file, null,
- function(object, res) {
- try {
- manager.index_file_finish(res);
- } catch (e) {
- logError(e, 'Error indexing the getting started PDF');
- }
- });
} catch (e) {
checkNextFile.apply(this);
+ return;
}
+
+ this.gettingStartedLocation = file.get_parent();
+
+ manager.index_file_async(file, null,
+ function(object, res) {
+ try {
+ manager.index_file_finish(res);
+ } catch (e) {
+ logError(e, 'Error indexing the getting started PDF');
+ }
+ });
}));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]