Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
Why Exception is not instance of Throwable?

I think in all programming languages Exception class is instance of Throwable interface.

Take a look at following code which shows Exception is not instance of Throwable in php.

try {

    throw new InvalidArgumentException("error message");

} catch (InvalidArgumentException $e) {

    if ($e instanceof Exception) {
        echo '$e is exception';             // this line gets executed
    }

    if ($e instanceof Throwable) {
        echo '$e is throwable';             // but this one never
    }

}

It makes problem with chaining exceptions where Exception class constructor accepts Throwable in it's last argument.

php version: 5.6.23

Any solution?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Throwable is the base interface for any object that can be thrown via a throw statement in PHP 7, including Error and Exception. And your code produces: $e is exception $e is throwable if you have PHP version >= 7

But you have PHP version 5.6.23, so Throwable interface is not available for this version.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda