modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-07-02 21:46:47 +04:00
parent a46111d089
commit 0cd7db166f
2 changed files with 16 additions and 8 deletions

View File

@ -419,7 +419,13 @@ class StdMessenger implements _IMessenger {
$showTraceback = $this->checkLevel($level1);
foreach ($exceptions as $exception) {
# tout d'abord userMessage
if ($exception instanceof UserException) {
$userMessage = UserException::get_user_message($exception);
$showSummary = true;
} else {
$userMessage = UserException::get_summary($exception);
$showSummary = false;
}
if ($userMessage !== null && $showContent) {
if ($printActions) { $this->printActions(); $printActions = false; }
$this->_printGeneric($linePrefix, $level, $type, $userMessage, $indentLevel, $out);
@ -427,9 +433,11 @@ class StdMessenger implements _IMessenger {
# puis summary et traceback
if ($showTraceback) {
if ($printActions) { $this->printActions(); $printActions = false; }
if ($showSummary) {
$summary = UserException::get_summary($exception);
$traceback = UserException::get_traceback($exception);
$this->_printGeneric($linePrefix, $level1, $type, $summary, $indentLevel, $out);
}
$traceback = UserException::get_traceback($exception);
$this->_printGeneric($linePrefix, $level1, $type, $traceback, $indentLevel, $out);
}
}

View File

@ -235,12 +235,12 @@ Application::run(new class extends Application {
msg::section("Exceptions", function ($msg) {
$e = new Exception("message");
$u1 = new UserException("userMessage");
$u2 = new UserException("userMessage", "techMessage");
$u1 = new UserException("userMessage1");
$u2 = new UserException("userMessage2", "techMessage2");
$msg->title("avec message", function ($msg) use ($e, $u1, $u2) {
$msg->info(["exception", $e]);
$msg->info(["userException1", $u1]);
$msg->info(["userException2", $u2]);
$msg->info(["exception message", $e]);
$msg->info(["userException1 message", $u1]);
$msg->info(["userException2 message", $u2]);
});
$msg->title("sans message", function ($msg) use ($e, $u1, $u2) {
$msg->info($e);