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.
|
* quitter normalement, avec éventuellement un code d'erreur.
|
||||||
*/
|
*/
|
||||||
class ExitException extends UserException {
|
class ExitException extends UserException {
|
||||||
function __construct(int $exitcode=0, $user_message=null, Throwable $previous=null) {
|
function __construct(int $exitcode=0, $userMessage=null, Throwable $previous=null) {
|
||||||
parent::__construct($user_message, null, $exitcode, $previous);
|
parent::__construct($userMessage, null, $exitcode, $previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isError(): bool {
|
function isError(): bool {
|
||||||
|
|
|
@ -75,12 +75,13 @@ class UserException extends RuntimeException {
|
||||||
return implode("\n", $tbs);
|
return implode("\n", $tbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __construct($user_message, $tech_message=null, $code=0, ?Throwable $previous=null) {
|
function __construct($userMessage, $techMessage=null, $code=0, ?Throwable $previous=null) {
|
||||||
$this->userMessage = $user_message;
|
$this->userMessage = $userMessage;
|
||||||
if ($tech_message === null) $tech_message = $user_message;
|
if ($techMessage === null) $techMessage = $userMessage;
|
||||||
parent::__construct($tech_message, $code, $previous);
|
parent::__construct($techMessage, $code, $previous);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var ?string */
|
||||||
protected $userMessage;
|
protected $userMessage;
|
||||||
|
|
||||||
function getUserMessage(): ?string {
|
function getUserMessage(): ?string {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
namespace nur\sery\web\ext;
|
namespace nur\sery\web\curl;
|
||||||
|
|
||||||
use nur\sery\UserException;
|
use nur\sery\UserException;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
@ -7,16 +7,16 @@ use Throwable;
|
||||||
class CurlException extends UserException {
|
class CurlException extends UserException {
|
||||||
function __construct($ch, ?string $message=null, $code=0, ?Throwable $previous=null) {
|
function __construct($ch, ?string $message=null, $code=0, ?Throwable $previous=null) {
|
||||||
if ($message === null) $message = "(unknown error)";
|
if ($message === null) $message = "(unknown error)";
|
||||||
$user_message = $message;
|
$userMessage = $message;
|
||||||
$tech_message = null;
|
$techMessage = null;
|
||||||
if ($ch !== null) {
|
if ($ch !== null) {
|
||||||
$parts = [];
|
$parts = [];
|
||||||
$errno = curl_errno($ch);
|
$errno = curl_errno($ch);
|
||||||
if ($errno != 0) $parts[] = "errno: $errno";
|
if ($errno != 0) $parts[] = "errno: $errno";
|
||||||
$error = curl_error($ch);
|
$error = curl_error($ch);
|
||||||
if ($error != "") $parts[] = "error: $error";
|
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
|
<?php
|
||||||
namespace nur\sery\web\ext;
|
namespace nur\sery\web\curl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class curl: wrapper pour curl
|
* Class curl: wrapper pour curl
|
Loading…
Reference in New Issue