modifs.mineures sans commentaires
This commit is contained in:
parent
c29975879c
commit
54ba47fd28
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
namespace nur\sery\web\ext;
|
||||
namespace nur\sery\web\curl;
|
||||
|
||||
/**
|
||||
* Class curl: wrapper pour curl
|
Loading…
Reference in New Issue