ExceptionsLib LegacyErrorCatcher might be useful here? If mkdir fails, the code will output a PHP warning, which is somewhat ugly.