try { // ... } catch (BasicException $e) { try { throw new PMException($e->getAdditionalText(), $e->getClassObj(), $e->getFilePath(), $e->getMethod(), $e->getExceptionLine(), $e->getErrorModeId(), $e->getUserShortname()); } catch (BasicException $pm) { $pm->writeToDB(); $pm->outputInfo(); } // ... }