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>
This commit is contained in:
parent
1aee0516d6
commit
0efa82acf0
@ -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];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user