Ошибка Error

(PHP 7, PHP 8)

Π’Π²Π΅Π΄Π΅Π½ΠΈΠ΅

Класс Error β€” Π±Π°Π·ΠΎΠ²Ρ‹ΠΉ класс для Π²Π½ΡƒΡ‚Ρ€Π΅Π½Π½ΠΈΡ… ошибок PHP.

ΠžΠ±Π·ΠΎΡ€ класса

class Error implements Throwable {
/* Бвойства */
protected string $message = "";
private string $string = "";
protected int $code;
protected string $file = "";
protected int $line;
private array $trace = [];
private ?Throwable $previous = null;
/* ΠœΠ΅Ρ‚ΠΎΠ΄Ρ‹ */
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
final public function getMessage(): string
final public function getPrevious(): ?Throwable
final public function getCode(): int
final public function getFile(): string
final public function getLine(): int
final public function getTrace(): array
final public function getTraceAsString(): string
public function __toString(): string
private function __clone(): void
}

Бвойства

message

Π‘ΠΎΠΎΠ±Ρ‰Π΅Π½ΠΈΠ΅ ΠΎΠ± ошибкС

code

Код ошибки

file

НазваниС Ρ„Π°ΠΉΠ»Π°, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка

line

НомСр строки, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ Π²ΠΎΠ·Π½ΠΈΠΊΠ»Π° ошибка

previous

ΠŸΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰Π°Ρ ошибка ΠΈΠ»ΠΈ ΠΈΡΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅

string

Π‘Ρ‚Ρ€ΠΎΠΊΠΎΠ²ΠΎΠ΅ прСдставлСниС трассировки стСка

trace

Врассировка стСка Π² Π²ΠΈΠ΄Π΅ массива

Π‘ΠΎΠ΄Π΅Ρ€ΠΆΠ°Π½ΠΈΠ΅

  • Error::__construct β€” Π‘ΠΎΠ·Π΄Π°Ρ‘Ρ‚ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ класса Error
  • Error::getMessage β€” ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ сообщСниС ΠΎΠ± ошибкС
  • Error::getPrevious β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΏΡ€Π΅Π΄Ρ‹Π΄ΡƒΡ‰ΠΈΠΉ Throwable
  • Error::getCode β€” Π’ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΊΠΎΠ΄ ошибки
  • Error::getFile β€” ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ Ρ„Π°ΠΉΠ», Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΌ ΠΏΡ€ΠΎΠΈΠ·ΠΎΡˆΠ»Π° ошибка
  • Error::getLine β€” ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ Π½ΠΎΠΌΠ΅Ρ€ строки, Π² ΠΊΠΎΡ‚ΠΎΡ€ΠΎΠΉ ΠΏΡ€ΠΎΠΈΠ·ΠΎΡˆΠ»Π° ошибка
  • Error::getTrace β€” ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ трассировку стСка
  • Error::getTraceAsString β€” ΠŸΠΎΠ»ΡƒΡ‡Π°Π΅Ρ‚ трассировку стСка Π² Π²ΠΈΠ΄Π΅ строки
  • Error::__toString β€” Π‘Ρ‚Ρ€ΠΎΠΊΠΎΠ²ΠΎΠ΅ прСдставлСниС ошибки
  • Error::__clone β€” ΠšΠ»ΠΎΠ½ΠΈΡ€ΡƒΠ΅Ρ‚ ΠΎΡˆΠΈΠ±ΠΊΡƒ
οΌ‹Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ

ΠŸΡ€ΠΈΠΌΠ΅Ρ‡Π°Π½ΠΈΡ ΠΏΠΎΠ»ΡŒΠ·ΠΎΠ²Π°Ρ‚Π΅Π»Π΅ΠΉ 3 notes

up
48
whysteepy at gmail dot com ΒΆ
8 years ago
Lists of Throwable and Exception tree as of 7.2.0

    Error
      ArithmeticError
        DivisionByZeroError
      AssertionError
      ParseError
      TypeError
        ArgumentCountError
    Exception
      ClosedGeneratorException
      DOMException
      ErrorException
      IntlException
      LogicException
        BadFunctionCallException
          BadMethodCallException
        DomainException
        InvalidArgumentException
        LengthException
        OutOfRangeException
      PharException
      ReflectionException
      RuntimeException
        OutOfBoundsException
        OverflowException
        PDOException
        RangeException
        UnderflowException
        UnexpectedValueException
      SodiumException 

Find the script and output in the following links:
https://gist.github.com/mlocati/249f07b074a0de339d4d1ca980848e6a
https://3v4l.org/sDMsv

posted here http://php.net/manual/en/class.throwable.php
up
22
dams at php dot net ΒΆ
4 years ago
Lists of Throwable and Exception tree as of 8.1.0

Error
   ArithmeticError
      DivisionByZeroError
   AssertionError
   CompileError
      ParseError
   FiberError
   TypeError
      ArgumentCountError
   UnhandledMatchError
   ValueError
Exception
   ClosedGeneratorException
   DOMException
   ErrorException
   IntlException
   JsonException
   LogicException
      BadFunctionCallException
         BadMethodCallException
      DomainException
      InvalidArgumentException
      LengthException
      OutOfRangeException
   PharException
   ReflectionException
   RuntimeException
      OutOfBoundsException
      OverflowException
      PDOException
      RangeException
      UnderflowException
      UnexpectedValueException
   SodiumException

Find the script and output in the following links:
https://gist.github.com/mlocati/249f07b074a0de339d4d1ca980848e6a
https://3v4l.org/f8Boe

Initially posted by whysteepy at gmail dot com for PHP 7.2.0, based on the gist
up
-2
JustinasMalkas ΒΆ
10 years ago
If after PHP upgrade you're getting error "PHP Fatal error:  Cannot declare class error, because the name is already in use ...", you will have to rename your "error" class.
Since PHP 7 classname "Error" is predefined and used internally.