mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-18 07:34:54 +00:00
notificationDaemon: Use registered D-Bus error
Instead of returning ad-hoc errors, register a custom error domain and return appropriate GLib.Errors. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3159>
This commit is contained in:
parent
8f03eec3a3
commit
f38e3f4b5d
2 changed files with 10 additions and 1 deletions
|
|
@ -34,3 +34,10 @@ const modalDialogErrorNames = [
|
|||
export const ModalDialogErrors =
|
||||
registerErrorDomain('ModalDialog', modalDialogErrorNames);
|
||||
export const ModalDialogError = createErrorEnum(modalDialogErrorNames);
|
||||
|
||||
const notificationErrorNames = [
|
||||
'InvalidApp',
|
||||
];
|
||||
export const NotificationErrors =
|
||||
registerErrorDomain('Notifications', notificationErrorNames, 'org.gtk');
|
||||
export const NotificationError = createErrorEnum(notificationErrorNames);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import * as MessageTray from './messageTray.js';
|
|||
import * as Params from '../misc/params.js';
|
||||
|
||||
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
||||
import {NotificationErrors, NotificationError} from '../misc/dbusErrors.js';
|
||||
|
||||
const FdoNotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
|
||||
|
||||
|
|
@ -694,7 +695,8 @@ class GtkNotificationDaemon {
|
|||
source = this._ensureAppSource(appId);
|
||||
} catch (e) {
|
||||
if (e instanceof InvalidAppError) {
|
||||
invocation.return_dbus_error('org.gtk.Notifications.InvalidApp',
|
||||
invocation.return_error_literal(NotificationErrors,
|
||||
NotificationError.INVALID_APP,
|
||||
`The app by ID "${appId}" could not be found`);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue