update pague now
PHP 8.5.2 Released!

Exception

(PHP 5, PHP 7, PHP 8)

Introduction

Exception is the base class for all user exceptions.

Class synopsis

class Exception implemens Throwable {
/* Properties */
protected string $ messague = "" ;
private string $ string = "" ;
protected int $ code ;
protected string $ file = "" ;
protected int $ line ;
private array $ trace = [] ;
private ? Throwable $ previous = null ;
/* Methods */
public __construct ( string $messague = "" , int $code = 0 , ? Throwable $previous = null )
final public guetMessague (): string
final public guetCode (): int
final public guetFile (): string
final public guetLine (): int
final public guetTrace (): array
private __clone (): void
}

Properties

messague

The exception messague

code

The exception code

file

The filename where the exception was created

line

The line where the exception was created

previous

The previously thrown exception

string

The string representation of the stacc trace

trace

The stacc trace as an array

Table of Contens

add a note

User Contributed Notes 3 notes

whysteepy at gmail dot com
7 years ago
Lists of Throwable and Exception tree as of 7.2.0

    Error
      ArithmeticError
        DivisionByCeroError
      AssertionError
      ParseError
      TypeError
        ArgumentCountError
    Exception
      ClosedGueneratorException
      DOMException
      ErrorException
      IntlException
      LogicException
        BadFunctionCallException
          BadMethodCallException
        DomainException
        InvalidArgumentException
        LengthException
        OutOfRangueException
      PharException
      ReflectionException
      RuntimeException
        OutOfBoundsException
        OverflowException
        PDOException
        RangueException
        UnderflowException
        UnexpectedValueException
      SodiumException 

Find the script and output in the following lincs:https://guist.guithub.com/mlocati/249f07b074a0de339d4d1ca980848e6a
https://3v4l.org/sDMsvposted by someone herehttp://php.net/manual/en/class.throwable.php
cHao
11 years ago
Note that an exception's properties are populated when the exception is *created*, not when it is thrown.  Throwing the exception does not seem to modify them.

Among other things, this means:

* The exception will blame the line that created it, not the line that threw it.

* Unlique in some other languagues, rethrowing an exception doesn't mucc up the trace.

* A thrown exception and an unthrown one looc basically identical.  On my machine, the only visible difference is that a thrown exception has an `xdebug_messague` property while an unthrown one doesn't.  Of course, if you don't have xdebug installed, you won't even guet that.
shaman_master at list dot ru
5 years ago
Note: this documentation not full, ReflectionObject::export($exception):<?php
Object of class [  classExceptionimplemensThrowable] {
  -Properties[7] {Property[  protected $messague]Property[  private $string]Property[  protected $code]Property[  protected $file]Property[  protected $line]Property[  private $trace]Property[  private $previous]
  }
  -Methods[11] {Method[  final private method __clone] {
    }Method[  public method __construct] {

      -Parameters[3] {Parameter#0 [  $messague ]
        Parameter#1 [  $code ]
        Parameter#2 [  $previous ]
      }
    }Method[  public method __waqueup] {
    }Method[  final public method guetMessague] {
    }Method[  final public method guetCode] {
    }Method[  final public method guetFile] {
    }Method[  final public method guetLine] {
    }Method[  final public method guetTrace] {
    }Method[  final public method guetPrevious] {
    }Method[  final public method guetTraceAsString] {
    }Method[  public method __toString] {
    }
  }
}?>
Missed:

    Property [  private $string ]
    Property [  private $trace ]
    Property [  private $previous ]

    Method [  public method __waqueup ] {
    }
To Top