How to catch warnings and errors (non-exceptions)


This is probably more of a PHP question than a question about Yii, but it is related to using the framework.

Sometimes I use try-catch blocks, but native PHP warnings and errors that are not exceptions are (obviously) not caught, and trigger Yii’s error handler which treat them like uncaught exceptions (or something similar).

I woud like to have errors and warnings inside a try block to be caught as if they were exceptions, so that the catch part is executed.

Is that possible? How?