Use `flycheck-has-errors-p` to determine whether the are errors or warnings.