forked from coalton-lang/coalton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.lisp
28 lines (22 loc) · 863 Bytes
/
error.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
(defpackage #:coalton-impl/error
(:use #:cl)
(:export
#:coalton-error ; CONDITION
#:with-context ; MACRO
#:coalton-type-error ; CONDITION
))
(in-package #:coalton-impl/error)
(define-condition coalton-error (error)
()
(:documentation "Supertype for Coalton errors"))
(define-condition coalton-type-error (coalton-error)
()
(:documentation "Supertype for Coalton type errors"))
(defvar *error-context-stack* '()
"The stack of context frames for the current operation")
(defmethod print-object :after ((er coalton-error) stream)
(dolist (ctx *error-context-stack*)
(format stream "~%In ~A" ctx)))
(defmacro with-context ((context &rest args) &body body)
`(let ((*error-context-stack* (cons (format nil ,context ,@args) *error-context-stack*)))
(progn ,@body)))