PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/error.lisp

https://github.com/xlchen/gollum
Lisp | 53 lines | 20 code | 9 blank | 24 comment | 0 complexity | 98fa03448cd02d09dd2ad2b271f50210 MD5 | raw file
 1(in-package :gollum)
 2
 3
 4;; clx error handling
 5
 6  ;; *xerror-vector*
 7  ;;    unknown-error
 8  ;;    request-error                              ; 1  bad request code
 9  ;;    value-error                                ; 2  integer parameter out of range
10  ;;    window-error                               ; 3  parameter not a Window
11  ;;    pixmap-error                               ; 4  parameter not a Pixmap
12  ;;    atom-error                                 ; 5  parameter not an Atom
13  ;;    cursor-error                               ; 6  parameter not a Cursor
14  ;;    font-error                                 ; 7  parameter not a Font
15  ;;    match-error                                ; 8  parameter mismatch
16  ;;    drawable-error                             ; 9  parameter not a Pixmap or Window
17  ;;    access-error                               ; 10 attempt to access private resource
18  ;;    alloc-error                                ; 11 insufficient resources
19  ;;    colormap-error                             ; 12 no such colormap
20  ;;    gcontext-error                             ; 13 parameter not a GContext
21  ;;    id-choice-error                            ; 14 invalid resource ID for this connection
22  ;;    name-error                                 ; 15 font or color name does not exist
23  ;;    length-error                               ; 16 request length incorrect;
24  ;;                                               ;    internal Xlib error
25  ;;    implementation-error                       ; 17 server is defective
26
27(defparameter *error-handlers* (make-array 24 :initial-element #'xlib:default-error-handler))
28
29(defmacro define-error-handler (error-key actual-keys &body body)
30  (let ((fn-name (gensym)))
31    `(labels ((,fn-name (display error-key &rest key-vals &key asynchronous ,@actual-keys &allow-other-keys)
32		,@body))
33       (setf (elt *error-handlers* (position ,error-key xlib::*xerror-vector*)) #',fn-name))))
34
35;; errors in clx:
36;; access-error alloc-error atom-error closed-display colormap-error connection-failure cursor-error device-busy drawable-error font-error gcontext-error id-choice-error implementation-error length-error lookup-error match-error missing-parameter name-error pixmap-error reply-length-error reply-timeout request-error resource-error sequence-error server-disconnect unexpected-reply unknown-error value-error window-error
37(define-error-handler 'xlib:window-error (resource-id)
38  (dformat 1 "window-error received")
39  (if asynchronous
40      t
41      (apply #'error 'xlib:window-error :display display :error-key 'xlib:window-error key-vals)))
42
43(define-error-handler 'xlib:drawable-error ()
44  (dformat 1 "drawable-error received")
45  (if asynchronous
46      t
47      (apply #'error 'xlib:drawable-error :display display :error-key 'xlib:drawable-error key-vals)))
48
49;; gollum error handling
50
51(define-condition no-such-window (error)
52  ((xwindow :initarg :xwindow
53	    :reader xwindow)))