How to attach an exception to a syntactic location?

Following along with Beautiful Racket, I'm trying to implement the AP Computer Science Principles pseudo-code that is used on the exam.

So far, so good. Except that I'd like to have errors attach to the locations in the pseudocode where they're triggered. For example, there is a NOT x expression, which only makes sense for booleans. In my expander, I tried both this

(define-macro (ps-not EXPR)
  #'(if (not (boolean? EXPR))
          (error (format "NOT must be used with a boolean, given ~a" EXPR))
          (not EXPR)))

and this

(define (ps-not expr)
  (if (not (boolean? expr))
      (error (format "NOT must be used with a boolean, given ~a" expr))
      (not expr)))

but the error points unsurprisingly to the expander, not the file where the error is actually introduced.

The problem (I think) is that I need to have simplified the expression to the point where I can tell it's a boolean and at that point, the original srcloc location is long gone.

I figure there must be a way around this, and it's likely in the Beautiful Racket text, but I don't remember it and can't find it. Any help appreciated.