Browse code
chore: add condition
Edward authored on 20/04/2021 06:25:53
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -19,6 +19,11 @@ |
19 | 19 |
renders the model picked out by the controller. Normally, this is |
20 | 20 |
specialized using the DEFINE-VIEW macr")) |
21 | 21 |
|
22 |
+(define-condition view-error (error) |
|
23 |
+ ((%message :initarg :msg :reader msg)) |
|
24 |
+ (:default-initargs :msg "something's wrong") |
|
25 |
+ (:report (lambda (condition stream) |
|
26 |
+ (format stream "Error in view: ~a" (msg condition))))) |
|
22 | 27 |
|
23 | 28 |
(defgeneric styles (route) |
24 | 29 |
(:documentation "if you use class-based roues, this method provides |
... | ... |
@@ -53,7 +58,9 @@ |
53 | 58 |
|
54 | 59 |
Useful if one view name is specialized many times on different model classes: the controller can |
55 | 60 |
pass the container and then the view can recall itself on the contained items." |
56 |
- (view *view-name* model)) |
|
61 |
+ (if (boundp '*view-name*) |
|
62 |
+ (view *view-name* model) |
|
63 |
+ (error 'view-error :msg "Must call CALL-CURRENT-VIEW within a view"))) |
|
57 | 64 |
|
58 | 65 |
(defmacro as-route (name &rest r &key &allow-other-keys) |
59 | 66 |
"Create a lambda directing requests to the route for NAME. This uses the |