1(import [enum [Enum]])
2
3;; From src/protocol/Ack.hxx in mpd source
4(defclass ACKError [Enum]
5 [NOT_LIST 1
6 ARG 2
7 PASSWORD 3
8 PERMISSION 4
9 UNKNOWN 5
10 NO_EXIST 50
11 PLAYLIST_MAX 51
12 SYSTEM 52
13 PLAYLIST_LOAD 53
14 UPDATE_ALREADY 54
15 PLAYER_SYNC 55
16 EXIST 56])
17
18(defclass MPDException [Exception]
19 (defn --init-- [self code msg &optional [lst-num 0] [cur-cmd ""]]
20 (if (not (isinstance code ACKError))
21 (raise (TypeError "Exception code must be an ACKError")))
22 (setv self.code code)
23 (setv self.msg msg)
24 (setv self.lst-num lst-num)
25 (setv self.cur-cmd cur-cmd))
26
27 ;; Format: ACK [error@command_listNum] {current_command} message_text
28 (defn __str__ [self]
29 (% "ACK [%d@%d] {%s} %s" (, self.code.value self.lst-num
30 self.cur-cmd self.msg))))