[gnome-games] Catch or declare forgotten errors
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] Catch or declare forgotten errors
- Date: Mon, 24 Jul 2017 10:45:15 +0000 (UTC)
commit b7c7f0fbcd15170208d9e1e3fd2f72e88a8e42c4
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sat Jul 22 08:56:39 2017 +0200
Catch or declare forgotten errors
This fixes some compile time warnings.
src/database/database-uri-iterator.vala | 12 ++++++++++--
src/database/database.vala | 2 +-
src/retro/retro-runner.vala | 18 +++++++++++++++---
src/ui/application.vala | 10 ++++++++--
4 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/src/database/database-uri-iterator.vala b/src/database/database-uri-iterator.vala
index 83928a8..ea05064 100644
--- a/src/database/database-uri-iterator.vala
+++ b/src/database/database-uri-iterator.vala
@@ -5,11 +5,16 @@ private class Games.DatabaseUriIterator : Object, UriIterator {
SELECT uri FROM game_resources;
""";
- private Sqlite.Statement statement;
+ private Sqlite.Statement? statement;
private Uri? uri;
internal DatabaseUriIterator (Sqlite.Database database) {
- statement = Database.prepare (database, SELECT_GAME_RESOURCE_QUERY);
+ try {
+ statement = Database.prepare (database, SELECT_GAME_RESOURCE_QUERY);
+ }
+ catch (Error e) {
+ debug (e.message);
+ }
}
public new Uri? get () {
@@ -17,6 +22,9 @@ private class Games.DatabaseUriIterator : Object, UriIterator {
}
public bool next () {
+ if (statement == null)
+ return false;
+
if (statement.step () != Sqlite.ROW)
return false;
diff --git a/src/database/database.vala b/src/database/database.vala
index 1cc0d3a..ee9a54c 100644
--- a/src/database/database.vala
+++ b/src/database/database.vala
@@ -37,7 +37,7 @@ private class Games.Database : Object {
throw new DatabaseError.EXECUTION_FAILED ("Execution failed.");
}
- public bool has_uri (Uri uri) {
+ public bool has_uri (Uri uri) throws Error {
var statement = prepare (database, HAS_URI_QUERY);
bind_text (statement, "$URI", uri.to_string ());
diff --git a/src/retro/retro-runner.vala b/src/retro/retro-runner.vala
index bc5d67d..adeec2d 100644
--- a/src/retro/retro-runner.vala
+++ b/src/retro/retro-runner.vala
@@ -313,7 +313,14 @@ public class Games.RetroRunner : Object, Runner {
if (!is_initialized)
return;
- core.set_current_media (media_set.selected_media_number);
+ try {
+ core.set_current_media (media_set.selected_media_number);
+ }
+ catch (Error e) {
+ debug (e.message);
+
+ return;
+ }
var media_number = media_set.selected_media_number;
@@ -331,9 +338,14 @@ public class Games.RetroRunner : Object, Runner {
if (uris.length == 0)
return;
- var uri = uris[0];
+ try {
+ core.set_current_media (media_set.selected_media_number);
+ }
+ catch (Error e) {
+ debug (e.message);
- core.set_current_media (media_set.selected_media_number);
+ return;
+ }
try {
save_media_data ();
diff --git a/src/ui/application.vala b/src/ui/application.vala
index ac80e07..218e3b7 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -279,8 +279,14 @@ public class Games.Application : Gtk.Application {
}
private async void add_cached_uri (Uri uri) {
- if (database != null)
- database.add_uri (uri);
+ try {
+ if (database != null)
+ database.add_uri (uri);
+ }
+ catch (Error e) {
+ debug (e.message);
+ }
+
yield game_collection.add_uri (uri);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]