From abde4e660398b34faa24475c2e3c6ce17c2686d5 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Wed, 21 Dec 2016 10:54:03 -0800 Subject: [PATCH] [reporting] Fail loudly when we can't log an error Summary: When you try to log an error on a procedure P and a summary for P doesn't exist, the error gets quietly dropped on the floor. But we should fail loudly instead, because this should only happen in the case of a user error. Got burned by this today; I was trying to log an error on the *caller* of `Integer.parseInt`, but was accidentally logging it to `Integer.parseInt` itself instead. Since no summary for that method exists, my error wasn't appearing. Reviewed By: jvillard, jeremydubreil Differential Revision: D4355546 fbshipit-source-id: db2a0e6 --- infer/src/backend/reporting.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/infer/src/backend/reporting.ml b/infer/src/backend/reporting.ml index 5e631cfd7..00c35ae06 100644 --- a/infer/src/backend/reporting.ml +++ b/infer/src/backend/reporting.ml @@ -63,7 +63,12 @@ let log_issue | Some summary -> let err_log = summary.Specs.attributes.ProcAttributes.err_log in log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr exn - | None -> () + | None -> + failwithf + "Trying to report error on procedure %a, but cannot because no summary exists for this \ + procedure. Did you mean to log the error on the caller of %a instead?" + Procname.pp proc_name + Procname.pp proc_name let log_error = log_issue Exceptions.Kerror let log_warning = log_issue Exceptions.Kwarning