Skip to content

Commit

Permalink
Some small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan-Nox committed Mar 30, 2022
1 parent 2c480ef commit 083585d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion backend/class/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function initialize(): void
parent::initialize();
$data = JsonHelper::decodeFileToArray(self::getPath());
if (empty($data)) {
throw new ConfigurationException('ENVIRONMENT_INVALID', E_ERROR);
throw new ConfigurationException('ENVIRONMENT_INVALID', E_ERROR, ['path'=>self::getPath()]);
}
$this->add($data);
self::$loaded = true;
Expand Down
39 changes: 22 additions & 17 deletions backend/class/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,30 @@ public static function handleException(\Exception $exception, int $errorLevel =
*/
private static function output(\Exception $exception): void
{
if (error_reporting() === 0) {
return;
}
$file = basename($exception->getFile());
$file = Path::LOG_DIR . "exception_{$file}_{$exception->getLine()}.html";
$errorPage = FrontendHelper::parseFile(Path::getInheritedPath('frontend/page/errorinfo.php'), $exception);
file_put_contents($file, $errorPage);
if (defined('NK_ERROR_OUTPUT') && NK_ERROR_OUTPUT !== true) {
return;
}
if (! headers_sent()) {
header(HttpResponse::HEADER_ERROR);
}
if (Environment::runs(Environment::PRODUCTION)) {
echo FrontendHelper::parseFile(Path::getInheritedPath('frontend/page/error.php'));
try {
if (error_reporting() === 0) {
return;
}
$file = basename($exception->getFile());
$file = Path::LOG_DIR . "exception_{$file}_{$exception->getLine()}.html";
$errorPage = FrontendHelper::parseFile(Path::getInheritedPath('frontend/page/errorinfo.php'), $exception);
file_put_contents($file, $errorPage);
if (defined('NK_ERROR_OUTPUT') && NK_ERROR_OUTPUT !== true) {
return;
}
if (! headers_sent()) {
header(HttpResponse::HEADER_ERROR);
}
if (Environment::runs(Environment::PRODUCTION)) {
echo FrontendHelper::parseFile(Path::getInheritedPath('frontend/page/error.php'));
exit(CliResponse::EXITCODE_ERROR);
}
echo $errorPage;
exit(CliResponse::EXITCODE_ERROR);
} catch (\Exception $error) {
var_dump($error);
die();
}
echo $errorPage;
exit(CliResponse::EXITCODE_ERROR);
}

/**
Expand Down
1 change: 0 additions & 1 deletion backend/class/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ abstract class Exception extends \Exception
*/
final public function __construct(string $code, int $level, $info = null)
{
file_put_contents('/var/www/_log/exceptions.log', chr(10) . $code, 8);
parent::__construct($code, $level);
$this->message = $code;
$this->code = $code;
Expand Down
2 changes: 1 addition & 1 deletion backend/class/Helper/LinkHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
abstract class LinkHelper
{
/** @var bool Encrypt links to obfuscate the underlying mvc? */
public static bool $encryptLinks = false;
public static bool $encryptLinks = true;
/** @var string The password */
public static string $secret = 'k26p555ug9d72j028f2dprknf';

Expand Down

0 comments on commit 083585d

Please sign in to comment.