Improve error handling in filter creation.