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
@ -34,3 +34,10 @@ const modalDialogErrorNames = [
|
|||||||
export const ModalDialogErrors =
|
export const ModalDialogErrors =
|
||||||
registerErrorDomain('ModalDialog', modalDialogErrorNames);
|
registerErrorDomain('ModalDialog', modalDialogErrorNames);
|
||||||
export const ModalDialogError = createErrorEnum(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 * as Params from '../misc/params.js';
|
||||||
|
|
||||||
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
||||||
|
import {NotificationErrors, NotificationError} from '../misc/dbusErrors.js';
|
||||||
|
|
||||||
const FdoNotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
|
const FdoNotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
|
||||||
|
|
||||||
@ -694,7 +695,8 @@ class GtkNotificationDaemon {
|
|||||||
source = this._ensureAppSource(appId);
|
source = this._ensureAppSource(appId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof InvalidAppError) {
|
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`);
|
`The app by ID "${appId}" could not be found`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user