zeg1jeux/lib/ErrorsHandler.class.php

65 lines
1.4 KiB
PHP
Raw Normal View History

2022-11-03 23:58:00 +01:00
<?php
class ErrorsHandler {
2023-03-16 04:12:48 +01:00
public function __construct () {
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
}
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
static public function kaput ($errorMsgs) {
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
ob_get_clean(); // to prevent error message to display inside an HTML container (case of error generated by get method calls)
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
if (!is_array($errorMsgs)) {
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
$errorMsgs = explode("\n", $errorMsgs);
}
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
echo '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>'. ('Erreur critique') . '</title>
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
<style>
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
div {
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
overflow: auto;
word-wrap: break-word;
background-color: hsl(0, 100%, 69%);
color: hsl(0, 100%, 19%);
margin: 1em;
padding: 1em;
border-radius: 1em;
position: fixed;
top: 0;
left: 0;
width: calc(100% - 4em);
max-height: calc(100vh - 4em);
}
</style>
</head>
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
<body>
<div>';
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
foreach ($errorMsgs as $msg) {
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
echo '<pre>' . print_r($msg, true) . '</pre>';
}
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
echo '
</div>
</body>
</html>';
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
die;
}
2022-11-03 23:58:00 +01:00
2023-03-16 04:12:48 +01:00
}