forked from fukamachi/qlot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.lisp
61 lines (51 loc) · 2.16 KB
/
errors.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(defpackage #:qlot/errors
(:use #:cl)
(:export #:qlot-error
#:qlot-simple-error
#:unknown-source
#:invalid-definition
#:duplicate-project
#:qlfile-parse-failed
#:ros-command-error
#:command-not-found))
(in-package #:qlot/errors)
(define-condition qlot-error (error) ())
(define-condition qlot-simple-error (qlot-error simple-error) ())
(define-condition qlot-syntax-error (qlot-error) ())
(define-condition unknown-source (qlot-syntax-error)
((name :initarg :name))
(:report (lambda (condition stream)
(format stream "Unknown source: ~A"
(slot-value condition 'name)))))
(define-condition invalid-definition (qlot-syntax-error)
((source :initarg :source)
(usage :initarg :usage))
(:report (lambda (condition stream)
(format stream "Invalid definition of '~(~A~)'.~%[usage] ~A"
(slot-value condition 'source)
(slot-value condition 'usage)))))
(define-condition duplicate-project (qlot-syntax-error)
((name :initarg :name))
(:report (lambda (condition stream)
(format stream "Duplicate project: ~A"
(slot-value condition 'name)))))
(define-condition qlfile-parse-failed (qlot-error)
((file :initarg :file)
(lineno :initarg :lineno)
(line :initarg :line)
(error :initarg :error))
(:report (lambda (condition stream)
(with-slots (file lineno line error) condition
(format stream "Error raised while parsing '~A' at line ~A:~2% ~A~2%~A"
file lineno line error)))))
(define-condition ros-command-error (qlot-error)
((message :initarg :message))
(:report (lambda (condition stream)
(princ (slot-value condition 'message) stream))))
(defun ros-command-error (format-control &rest format-arguments)
(error 'ros-command-error
:message (apply #'format nil format-control format-arguments)))
(define-condition command-not-found (ros-command-error)
((command :initarg :command))
(:report (lambda (condition stream)
(format stream "Command not found: ~A" (slot-value condition 'command)))))