modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-05-20 17:35:53 +04:00
parent c29975879c
commit 54ba47fd28
4 changed files with 13 additions and 12 deletions

View File

@ -8,8 +8,8 @@ use Throwable;
* quitter normalement, avec éventuellement un code d'erreur.
*/
class ExitException extends UserException {
function __construct(int $exitcode=0, $user_message=null, Throwable $previous=null) {
parent::__construct($user_message, null, $exitcode, $previous);
function __construct(int $exitcode=0, $userMessage=null, Throwable $previous=null) {
parent::__construct($userMessage, null, $exitcode, $previous);
}
function isError(): bool {

View File

@ -75,12 +75,13 @@ class UserException extends RuntimeException {
return implode("\n", $tbs);
}
function __construct($user_message, $tech_message=null, $code=0, ?Throwable $previous=null) {
$this->userMessage = $user_message;
if ($tech_message === null) $tech_message = $user_message;
parent::__construct($tech_message, $code, $previous);
function __construct($userMessage, $techMessage=null, $code=0, ?Throwable $previous=null) {
$this->userMessage = $userMessage;
if ($techMessage === null) $techMessage = $userMessage;
parent::__construct($techMessage, $code, $previous);
}
/** @var ?string */
protected $userMessage;
function getUserMessage(): ?string {

View File

@ -1,5 +1,5 @@
<?php
namespace nur\sery\web\ext;
namespace nur\sery\web\curl;
use nur\sery\UserException;
use Throwable;
@ -7,16 +7,16 @@ use Throwable;
class CurlException extends UserException {
function __construct($ch, ?string $message=null, $code=0, ?Throwable $previous=null) {
if ($message === null) $message = "(unknown error)";
$user_message = $message;
$tech_message = null;
$userMessage = $message;
$techMessage = null;
if ($ch !== null) {
$parts = [];
$errno = curl_errno($ch);
if ($errno != 0) $parts[] = "errno: $errno";
$error = curl_error($ch);
if ($error != "") $parts[] = "error: $error";
if ($parts) $tech_message = implode(", ", $parts);
if ($parts) $techMessage = implode(", ", $parts);
}
parent::__construct($user_message, $tech_message, $code, $previous);
parent::__construct($userMessage, $techMessage, $code, $previous);
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace nur\sery\web\ext;
namespace nur\sery\web\curl;
/**
* Class curl: wrapper pour curl