PHP has more specific exceptions?

Asked

Viewed 25 times

0

I usually see that everyone uses PHP with Pdoexception or the more generic Exception $e, but PHP has exceptions more specific? as in JAVA Nullpointerexception or Arithmeticexception or Numberformatexception

And do I use them the same way as Exception $e? Only replacing Exception with the more specific

  • And the second part of the question @Wallace Maxters?

  • Yes, the syntax does not change from one exception to the other. Related: How and when to use exceptions in PHP?

  • Thanks for the help

  • Each Exception has its own methods that are suitable for the task. For example the PDOException has a property that returns the SQLSTATE which is useful to know what kind of error happened to the query or database, which is not suitable for handling a file.

  • If you need something more specific, just create your own exceptions...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.