forked from samirose/sicp-compiler-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compilation-error.sls
35 lines (25 loc) · 1008 Bytes
/
compilation-error.sls
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
#!r6rs
(library
(compilation-error)
(export make-compilation-error compilation-error?
compilation-error-message compilation-error-object
raise-as-error raise-if-error
raise-compilation-error set-compilation-error-handler!)
(import (rnrs base))
(define compilation-error-handler error)
(define (set-compilation-error-handler! handler)
(set! compilation-error-handler handler))
(define (make-compilation-error message object)
(list make-compilation-error message object))
(define (compilation-error? x)
(and (list? x) (eq? (car x) make-compilation-error)))
(define (compilation-error-message e) (cadr e))
(define (compilation-error-object e) (caddr e))
(define (raise-as-error e)
(raise-compilation-error (compilation-error-message e) (compilation-error-object e)))
(define (raise-if-error x)
(if (compilation-error? x)
(raise-as-error x)))
(define (raise-compilation-error message object)
(compilation-error-handler message object))
)