Throwable

- « InternalIterator::valid

- Throwable::getMessage »

- PHP Manual
- Predefined Interfaces and Classes
- Throwable

# Throwable

(PHP 7, PHP 8)

## Introduction

Throwable is the base interface for any object that can be thrown via a `throw` statement, including Error and Exception.

> Note:

> PHP classes cannot implement the Throwable interface directly, and must instead extend Exception.

## Interface synopsis

interface Throwable extends Stringable {
/* Methods */
public getMessage(): string
public getCode(): int
public getFile(): string
public getLine(): int
public getTrace(): array
public getTraceAsString(): string
public getPrevious(): ?Throwable
public __toString(): string
/* Inherited methods */
public Stringable::__toString(): string
}

## Changelog

Version | Description
--- | ---
8.0.0 | Throwable implements Stringable now.

## Table of Contents

- Throwable::getMessage — Gets the message
- Throwable::getCode — Gets the exception code
- Throwable::getFile — Gets the file in which the object was created
- Throwable::getLine — Gets the line on which the object was instantiated
- Throwable::getTrace — Gets the stack trace
- Throwable::getTraceAsString — Gets the stack trace as a string
- Throwable::getPrevious — Returns the previous Throwable
- Throwable::__toString — Gets a string representation of the thrown object