racket/collects/syntax/private/util/error.ss
Ryan Culpepper 3e63caa887 merged changes from /branches/ryanc/sp2:
added syntax/parse library and documentation
  added syntax/id-table library and documentation

svn: r15376
2009-07-03 19:47:25 +00:00

17 lines
654 B
Scheme

#lang scheme/base
(provide wrong-syntax
current-syntax-context)
(define current-syntax-context (make-parameter #f))
(define (wrong-syntax stx #:extra [extras null] format-string . args)
(unless (or (eq? stx #f) (syntax? stx))
(raise-type-error 'wrong-syntax "syntax or #f" 0 (list* stx format-string args)))
(let* ([ctx (current-syntax-context)]
[blame (and (syntax? ctx) (syntax-property ctx 'report-errors-as))])
(raise-syntax-error (if (symbol? blame) blame #f)
(apply format format-string args)
ctx
(or stx ctx)
extras)))