- $stream = fopen($url, 'a');
- if ($this->filePermission !== null) {
- @chmod($url, $this->filePermission);
+ try {
+ $stream = fopen($url, 'a');
+ if ($this->filePermission !== null) {
+ @chmod($url, $this->filePermission);
+ }
+ } finally {
+ restore_error_handler();