[gnome-shell] screenshot: Return error if stream creation failed
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] screenshot: Return error if stream creation failed
- Date: Thu, 28 Jan 2021 21:52:03 +0000 (UTC)
commit 0efa82acf02ffbb017b5c58e9d954cfc1aea3f00
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Jan 25 12:32:26 2021 +0100
screenshot: Return error if stream creation failed
When we fail for some reason to open a stream to write the screenshot
to, we currently return `false` to the sender. That's not wrong, but
doesn't provide any hints on what caused the failure, so return the
underlying error instead.
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3618
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1589>
js/ui/screenshot.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index 29cf7c8977..05120e1a22 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -108,22 +108,24 @@ var ScreenshotService = class {
let stream = file.replace(null, false, Gio.FileCreateFlags.NONE, null);
return [stream, file];
} catch (e) {
- invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
+ invocation.return_gerror(e);
return [null, null];
}
}
+ let err;
for (let file of this._resolveRelativeFilename(filename)) {
try {
let stream = file.create(Gio.FileCreateFlags.NONE, null);
return [stream, file];
} catch (e) {
+ err = e;
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS))
break;
}
}
- invocation.return_value(GLib.Variant.new('(bs)', [false, '']));
+ invocation.return_gerror(err);
return [null, null];
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]