X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplatal.php;h=b911828ff181f27d581f70a906e5be5068e9c64b;hb=7f6d1063f7543f8e6c0e775dccdeff18626534cc;hp=06002ed5bdaef554608dc2ce911720fbe62f96e2;hpb=92d96cb7270caff156df7785b800a7a3084e8a16;p=platal.git diff --git a/classes/platal.php b/classes/platal.php index 06002ed..b911828 100644 --- a/classes/platal.php +++ b/classes/platal.php @@ -360,18 +360,35 @@ abstract class Platal $this->path = 'index'; } - $page->assign('platal', $this); - switch ($this->call_hook($page)) { - case PL_FORBIDDEN: - $this->mods['core']->handler_403($page); - break; + try { + $page->assign('platal', $this); + switch ($this->call_hook($page)) { + case PL_FORBIDDEN: + $this->mods['core']->handler_403($page); + break; + + case PL_NOT_FOUND: + $this->mods['core']->handler_404($page); + break; + + case PL_WIKI: + return PL_WIKI; + } + } catch (Exception $e) { + header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); - case PL_NOT_FOUND: - $this->mods['core']->handler_404($page); - break; + $file = fopen(self::globals()->spoolroot . '/spool/tmp/site_errors', 'a'); + fwrite($file, '
' . date('Y-m-d G:i:s') . '
' + . '
' . pl_entities("" . $e) . '
' + . '------------------------------------------------------------------' . "\n"); + fclose($file); - case PL_WIKI: - return PL_WIKI; + if (self::globals()->debug) { + $page->kill(pl_entities($e->getMessage()) + . '
' . pl_entities("" . $e) . '
'); + } else { + $page->kill(pl_entities($e->getMessage())); + } } $page->assign('platal', $this); @@ -426,19 +443,13 @@ abstract class Platal public static function assert($cond, $error, $userfriendly = null) { - global $globals; if ($cond === false) { - header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error'); - $file = fopen($globals->spoolroot . '/spool/tmp/assert_erros', 'a'); - fwrite($file, '
' . pl_entities($error) . '
\n'); - fclose($file); - if ($userfriendly == null) { $userfriendly = "Une erreur interne s'est produite. Merci de réessayer la manipulation qui a déclenché l'erreur ; si cela ne fonctionne toujours pas, merci de nous signaler le problème rencontré."; } - Platal::page()->kill($userfriendly); + throw new PlException($userfriendly, $error); } }