forked from the-little-typer/pie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pie-err.rkt
30 lines (27 loc) · 1.01 KB
/
pie-err.rkt
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
#lang racket/base
(require racket/string racket/port racket/match)
(require "locations.rkt")
(require "resugar.rkt")
(require "pretty.rkt")
(provide (all-defined-out))
(struct exn:fail:pie exn:fail (where)
#:property prop:exn:srclocs
(lambda (e)
(match (exn:fail:pie-where e)
[(list raw-src line col pos span)
;; DrRacket highlights more consistently if we
;; return an actual path for the source when
;; the source string corresponds to a valid
;; file on the user's machine.
(define src (if (and (string? raw-src)
(file-exists? raw-src))
(string->path raw-src)
raw-src))
(list (srcloc src line col pos span))]))
#:transparent)
(define (raise-pie-error where msg)
(raise (exn:fail:pie (with-output-to-string
(lambda ()
(pprint-message msg)))
(current-continuation-marks)
(location->srcloc where))))