-
Notifications
You must be signed in to change notification settings - Fork 29
/
conditions.lisp
41 lines (34 loc) · 1.49 KB
/
conditions.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
;;;; +----------------------------------------------------------------+
;;;; | DBUS |
;;;; +----------------------------------------------------------------+
(defpackage #:dbus/conditions
(:use #:cl)
(:export
#:dbus-error
#:authentication-error
#:authentication-error-command
#:authentication-error-argument
#:method-error
#:method-error-arguments))
(in-package #:dbus/conditions)
;;;; Condition types
(define-condition dbus-error (error)
()
(:documentation "The supertype for errors related to the DBUS
system."))
(define-condition authentication-error (dbus-error)
((command :initarg :command :reader authentication-error-command)
(argument :initarg :argument :reader authentication-error-argument))
(:report (lambda (condition stream)
(format stream "Authentication error, command ~S with argument ~S."
(authentication-error-command condition)
(authentication-error-argument condition)))))
(define-condition method-error (dbus-error)
((arguments :initarg :arguments :reader method-error-arguments))
(:report (lambda (condition stream)
(format stream "Method error: ~S."
(let ((all-args (method-error-arguments condition))
(first-arg (first (method-error-arguments condition))))
(if (stringp first-arg)
first-arg
all-args))))))