fix cleaning empty buffer in error_handler