Skip to content

Instantly share code, notes, and snippets.

@srcreigh
Created February 2, 2021 23:19
Show Gist options
  • Save srcreigh/a0a087adc26e15af0160e8866d48cd1c to your computer and use it in GitHub Desktop.
Save srcreigh/a0a087adc26e15af0160e8866d48cd1c to your computer and use it in GitHub Desktop.
How to add static compilation errors to Racket
#lang racket/base
(require (for-syntax racket/base syntax/parse))
(define-syntax (error stx)
(syntax-parse stx
[(_ ...) (raise-syntax-error #f "This is an error." stx)]))
;; The following line will be highlighted in the IDE and say "This is an error."
;; in DrRacket or racket-xp-mode for emacs.
(error 'hi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment