diff --git a/www/_include.php b/www/_include.php
index b5f506fa47fafffd947f995c107c3e254a2e96bb..22972aff4c2c8de2723cdfb9fac7412bad40a2f2 100644
--- a/www/_include.php
+++ b/www/_include.php
@@ -46,7 +46,8 @@ function SimpleSAML_exception_handler($exception)
         $e->show();
     } else {
         if (class_exists('Error') && $exception instanceof Error) {
-            $errno = $exception->getCode();
+            $code = $exception->getCode();
+            $errno = ($code > 0) ? $code : E_ERROR;
             $errstr = $exception->getMessage();
             $errfile = $exception->getFile();
             $errline = $exception->getLine();