You add the following S-exp to your configuration file (possibly the hook-mode hook function).
(defadvice flymake-post-syntax-check (before flymake-force-check-was-interrupted) (setq flymake-check-was-interrupted t)) (ad-activate 'flymake-post-syntax-check)
flymake throws an exception when the exit status is not equal to zero, and the compilation process was not interrupted. This S-exp forces flymake-check-was-interrupted to be true, and avoids the flymake exception.
source share