function dd() { if (Yolk::isDebug()) { headers_sent() || header('Content-type: text/plain; charset=UTF-8'); foreach (func_get_args() as $arg) { Yolk::dump($arg); } die; } }
/** * Default exception handler * @param \Exception $error * @param string $error_page the file containing the error page to include for production web apps * @return void */ public static function exception(\Exception $error, $error_page) { static::logException($error); if (Yolk::isCLI()) { Yolk::dump($error); } elseif (Yolk::isDebug()) { require __DIR__ . '/error.debug.php'; } else { require $error_page; } }
protected function error(\Exception $error, $context = []) { // if this isn't a 404 then log it and if we're in debug mode then throw it to Yolk's exception handler if (!$error instanceof exceptions\NotFoundException) { if (Yolk::isDebug()) { throw $error; } error_log(get_class($error) . ': ' . $error->getMessage() . ' [' . $error->getFile() . ':' . $error->getLine() . ']'); } // default to a 500 error $code = 500; $message = 'Internal Server Error'; // if it's an application error then use the code and message provided if ($error instanceof Exception) { $code = $error->getCode(); $message = $error->getMessage(); } // send an appropriate header if we still can if (!headers_sent()) { header("HTTP/1.1 {$code} {$message}"); } // do we have a specific error page? if (file_exists("{$this->path}/app/errors/{$code}.php")) { include "{$this->path}/app/errors/{$code}.php"; } elseif (file_exists("{$this->path}/app/errors/generic.php")) { include "{$this->path}/app/errors/generic.php"; } else { throw $error; } }