Failure final class
Minn\Http\Failure · public/minn/src/Minn/Http/Failure.php · 207 lines
What the public sees when the engine cannot answer: a plain page with no detail, while the detail goes to the log. Installed once per request, it sets PHP's error settings from the debug constants (display stays off unless WP_DEBUG and WP_DEBUG_DISPLAY ask for it) and catches the fatal errors PHP would otherwise print.
Constants and properties
| private | FATAL = 4437 | |
| private | static mixed $recorder | |
| private | static bool $display | Whether errors display for this request: display_errors, once the debug constants set it. |
| private | static bool $armed | Whether a failure right now may be recorded against an extension: only while the extensions boot. |
Public
| static | armRecovery(): void# | Opens the window in which a failure is an extension's fault: while the plugins and the theme's functions file load and the boot actions fire, code that fails fails for every visitor, so pausing it heals the site. A failure after that (a route, a shortcode, a template) answers to one request's input and is never grounds for a pause; it is logged and the request ends in the error page. | ||||||
| static | disarmRecovery(): void# | Closes the window armRecovery() opened. | ||||||
| static | onFatal(callable $recorder): void# | What to do with a fatal beyond showing the page: the engine records the extension it came from so the next request loads without it. Installed once the runtime is up, since it needs the database.
| ||||||
| static | install(array $constants, array $server): void# | Sets PHP's error settings from the debug constants as the reference's boot does (Runtime\DebugMode), and installs the error handlers. With WP_DEBUG off, or for a request that answers a machine, errors never display. In the first case the reference leaves php.ini's setting; the engine never shows a visitor PHP's errors. Detail is shown only while display_errors is on.
| ||||||
| static | report(Throwable $error): Minn\Http\Response# | Logs the cause; the page says only that something went wrong. | ||||||
| static | reportJson(Throwable $error): Minn\Http\Response# | The same, for a request that asked for JSON: a client that speaks REST is answered in REST, never handed the HTML error page. | ||||||
| static | internal(): Minn\Http\Response# | The 500 page. | ||||||
| static | databaseUnavailable(): Minn\Http\Response# | The 503 page the reference shows when the database cannot be reached. | ||||||
| static | maintenance(): Minn\Http\Response# | The 503 page while maintenance mode holds; monitors read the status, the retry hint, and the title. | ||||||
| static | detailed(string $class, string $message, string $file, int $line): Minn\Http\Response# | The same page with the cause on it, for a site that asked to see errors. Only ever reached when WP_DEBUG_DISPLAY (or WP_DEBUG) is on: a site that has not asked never learns this much from a response. |
Internals 5
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | discardOutput(): void# | Whatever a half-finished render left in the output buffers goes; the error page must stand alone. | |||
| private | note(Throwable $error): void# | Logs the failure, clears whatever a half-finished render left, and offers it to recovery. | |||
| private | record(array $error): void# | Hands the failure to the recorder, and never lets recovery itself take the request down: a site that cannot record a pause should still answer with the error page.
| |||
| private | dropin(string $file): Minn\Http\Response# | A drop-in's own page: what it prints, under the status it set (200 when it set none) and only the headers it sent itself, as the reference serves db-error.php when its database is away. | |||
| private | page(int $status, string $title, string $text, string $detail = ''): Minn\Http\Response# |
Nothing matches.