Skip to content

Commit

Permalink
Split out full_status_json_of_errors
Browse files Browse the repository at this point in the history
Summary: I want to send this object over the persistent connection, wrapped with some other info.

Reviewed By: avikchaudhuri

Differential Revision: D4653502

fbshipit-source-id: c4c93e4df334f6c557d697e220dff6f16deccf1e
  • Loading branch information
nmote authored and facebook-github-bot committed Mar 6, 2017
1 parent 2278be3 commit 160dde1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/common/errors/errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -737,21 +737,25 @@ module Json_output = struct
let f = json_of_error_with_context ~strip_root ~stdin_file in
Hh_json.JSON_Array (List.map f (ErrorSet.elements errors))

let print_errors
~out_channel
~strip_root ?(pretty=false) ?(profiling=None) ?(stdin_file=None)
el =
let full_status_json_of_errors ~strip_root ?(profiling=None) ?(stdin_file=None) errors =
let open Hh_json in

let props = [
"flowVersion", JSON_String FlowConfig.version;
"errors", json_of_errors_with_context ~strip_root ~stdin_file el;
"passed", JSON_Bool (ErrorSet.is_empty el);
"errors", json_of_errors_with_context ~strip_root ~stdin_file errors;
"passed", JSON_Bool (ErrorSet.is_empty errors);
] in
let props = match profiling with
| None -> props
| Some profiling -> props @ Profiling_js.to_json_properties profiling in
let res = JSON_Object props in
JSON_Object props

let print_errors
~out_channel
~strip_root ?(pretty=false) ?(profiling=None) ?(stdin_file=None)
el =
let open Hh_json in
let res = full_status_json_of_errors ~strip_root ~profiling ~stdin_file el in
output_string out_channel (json_to_string ~pretty res);
flush out_channel
end
Expand Down
7 changes: 7 additions & 0 deletions src/common/errors/errors.mli
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ module Json_output : sig
ErrorSet.t ->
Hh_json.json

val full_status_json_of_errors :
strip_root: Path.t option ->
?profiling:Profiling_js.t option ->
?stdin_file:stdin_file ->
ErrorSet.t ->
Hh_json.json

val print_errors:
out_channel:out_channel ->
strip_root: Path.t option ->
Expand Down

0 comments on commit 160dde1

Please sign in to comment.