[gnome-shell] screenshot: Return error if stream creation failed



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]