Jump to main content Jump to doc navigation

modX::sendError

Send the user to a type-specific core error page and halt PHP execution. MODX ships two such pages: unavailable (the default) and fatal.

Syntax

void sendError ([string $type = ''], [array $options = array()])
  • $type (string) Name of the error template in core/error/{type}.include.php. When empty, the value is taken from the error_type key of $options, defaulting to unavailable.
  • $options (array) Values used to build the error page:
    • error_pagetitle — the <title> of the page (default Error 503: Service temporarily unavailable)
    • error_message — the body HTML (default <p>Site temporarily unavailable.</p>)
    • error_header — the raw HTTP header line sent (default HTTP/1.1 503 Service Unavailable)
    • error_type — fallback for an empty $type

The method clears output buffers, sends the header, prints the page, closes the session and calls exit() — nothing after it runs.

Examples

Send an Unavailable 503 error page.

$modx->sendError('unavailable');

Send a Fatal 500 error page.

$modx->sendError('fatal');

See Also

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

$194 per month—let's make that $500!

Learn more