Summary: Before: to report an issue type, wrap it in an exception type then pass that around and translate it back to an issue type at some point. After: no. Except biabduction, which was built like this and uses raising of exceptions to stop the analysis too. Reviewed By: dulmarod Differential Revision: D21904589 fbshipit-source-id: cb8446f38master
parent
8a1c10f8a1
commit
358c8b34ac
@ -0,0 +1,22 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
module L = Logging
|
||||||
|
module F = Format
|
||||||
|
|
||||||
|
type t = {issue_type: IssueType.t; description: Localise.error_desc; ocaml_pos: L.ocaml_pos option}
|
||||||
|
|
||||||
|
(** pretty print an error *)
|
||||||
|
let pp_err ?severity_override loc issue_type desc ocaml_pos_opt fmt () =
|
||||||
|
let severity = Option.value severity_override ~default:issue_type.IssueType.default_severity in
|
||||||
|
let kind =
|
||||||
|
IssueType.string_of_severity
|
||||||
|
(if IssueType.equal_severity severity Info then Warning else severity)
|
||||||
|
in
|
||||||
|
F.fprintf fmt "%a:%d: %s: %a %a%a@\n" SourceFile.pp loc.Location.file loc.Location.line kind
|
||||||
|
IssueType.pp issue_type Localise.pp_error_desc desc L.pp_ocaml_pos_opt ocaml_pos_opt
|
@ -0,0 +1,26 @@
|
|||||||
|
(*
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*)
|
||||||
|
|
||||||
|
open! IStd
|
||||||
|
module L = Logging
|
||||||
|
|
||||||
|
(** An issue about to be reported to the user *)
|
||||||
|
type t =
|
||||||
|
{ issue_type: IssueType.t
|
||||||
|
; description: Localise.error_desc
|
||||||
|
; ocaml_pos: L.ocaml_pos option (** location in the infer source code *) }
|
||||||
|
|
||||||
|
val pp_err :
|
||||||
|
?severity_override:IssueType.severity
|
||||||
|
-> Location.t
|
||||||
|
-> IssueType.t
|
||||||
|
-> Localise.error_desc
|
||||||
|
-> Logging.ocaml_pos option
|
||||||
|
-> Format.formatter
|
||||||
|
-> unit
|
||||||
|
-> unit
|
||||||
|
(** pretty print an error *)
|
Loading…
Reference in new issue