catch error if pattern is not found