refactored exception handling on php process