Skip to content
Marcus edited this page Oct 28, 2015 · 1 revision

The #error directive throws an exception. This can be useful to enforce invariants.


Syntax

$$#error <message> /$$

$$#error$$
   <message_body>
$$/error$$

<message>: any string not containing Jefferson markers
<message_body>: any string, will be compiled as Jefferson "code"
  • May be empty: yes
  • May be nested: yes (note: this is probably not very useful)

Custom Exception Type

By default the exception type used is Exception. It is possible to override this behaviour by passing the relevant exception type to the constructor of the directive. This exception type should contain a public constructor should accepting a single String argument.

Examples

$$#if HAVE_FOO and HAVE_BAR$$
   $$#error Cannot have foo and bar at the same time. /$$
$$/if$$
Clone this wiki locally