Skip to content

Commit 349fd9e

Browse files
authored
Merge pull request #1093 from bloomberg/make_world_better_error_handling
fix #1075
2 parents eee80b5 + 51b67c7 commit 349fd9e

File tree

7 files changed

+41
-39
lines changed

7 files changed

+41
-39
lines changed

docs/Manual.html

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ <h1><a href="https://github.com/bloomberg/bucklescript">BuckleScript</a> User Ma
656656
<li><a href="#_contributing_to_code_bsb_exe_code">Contributing to <code>bsb.exe</code></a></li>
657657
<li><a href="#_contributing_to_code_bsc_exe_code">Contributing to <code>bsc.exe</code></a></li>
658658
<li><a href="#_contributing_to_the_runtime">Contributing to the runtime</a></li>
659+
<li><a href="#_contributing_to_the_documentation">Contributing to the documentation</a></li>
659660
</ul>
660661
</li>
661662
<li><a href="#_comparisons">Comparisons</a>
@@ -4440,37 +4441,30 @@ <h3 id="_simple_ocaml_type"><a class="anchor" href="#_simple_ocaml_type"></a>Sim
44404441
<tr>
44414442
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>'a Js.Null.t</code></p></td>
44424443
<td class="tableblock halign-left valign-top"><div><div class="paragraph">
4443-
<p>either <code>'a</code> or <code>null</code></p>
4444+
<p>either <code>'a</code> or <code>null</code>. <code>Js.Null.empty</code> represents <code>null</code> too.</p>
44444445
</div>
44454446
<div class="listingblock">
44464447
<div class="title">Js.Null module</div>
44474448
<div class="content">
44484449
<pre class="pygments highlight"><code data-lang="ocaml"><span class="tok-k">val</span> <span class="tok-n">to_opt</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span> <span class="tok-o">-&gt;</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">option</span>
4449-
4450+
<span class="tok-k">val</span> <span class="tok-n">from_opt</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">option</span> <span class="tok-o">-&gt;</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span>
44504451
<span class="tok-k">val</span> <span class="tok-n">return</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-o">-&gt;</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span>
4451-
44524452
<span class="tok-k">val</span> <span class="tok-n">test</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span> <span class="tok-o">-&gt;</span> <span class="tok-kt">bool</span></code></pre>
44534453
</div>
44544454
</div></div></td>
44554455
</tr>
44564456
<tr>
44574457
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>'a Js.Undefined.t</code></p></td>
44584458
<td class="tableblock halign-left valign-top"><div><div class="paragraph">
4459-
<p>either <code>'a</code> or <code>undefined</code></p>
4460-
</div>
4461-
<div class="listingblock">
4462-
<div class="title">Js.Undefined</div>
4463-
<div class="content">
4464-
<pre class="pygments highlight"><code data-lang="ocaml"><span class="tok-k">val</span> <span class="tok-n">to_opt</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span> <span class="tok-o">-&gt;</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">option</span>
4465-
<span class="tok-k">val</span> <span class="tok-n">return</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-o">-&gt;</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span>
4466-
<span class="tok-k">val</span> <span class="tok-n">test</span> <span class="tok-o">:</span> <span class="tok-k">&#39;</span><span class="tok-n">a</span> <span class="tok-n">t</span> <span class="tok-o">-&gt;</span> <span class="tok-kt">bool</span></code></pre>
4467-
</div>
4459+
<p>either <code>'a</code> or <code>undefined</code>.
4460+
Same operations as <code>'a Js.Null.t</code>.</p>
44684461
</div></div></td>
44694462
</tr>
44704463
<tr>
44714464
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>'a Js.Null_undefined.t</code></p></td>
44724465
<td class="tableblock halign-left valign-top"><div><div class="paragraph">
4473-
<p>either <code>'a</code>, <code>null</code> or <code>undef</code></p>
4466+
<p>either <code>'a</code>, <code>null</code> or <code>undef</code>.
4467+
Same operations as <code>'a Js.Null.t</code>.</p>
44744468
</div></div></td>
44754469
</tr>
44764470
</tbody>
@@ -4730,6 +4724,12 @@ <h3 id="_contributing_to_the_runtime"><a class="anchor" href="#_contributing_to_
47304724
<p><code>npm run cover</code></p>
47314725
</div>
47324726
</div>
4727+
<div class="sect2">
4728+
<h3 id="_contributing_to_the_documentation"><a class="anchor" href="#_contributing_to_the_documentation"></a>Contributing to the documentation</h3>
4729+
<div class="paragraph">
4730+
<p>You&#8217;ll need <a href="http://asciidoctor.org/">Asciidoctor</a> installed. Modify the section you want in <code>site/docsource/</code>, then run <code>site/docsource/build.sh</code>.</p>
4731+
</div>
4732+
</div>
47334733
</div>
47344734
</div>
47354735
<div class="sect1">

jscomp/bin/bsb.ml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6673,7 +6673,7 @@ val set_package_specs_from_array : Ext_json.t array -> unit
66736673
val get_generate_merlin : unit -> bool
66746674
val set_generate_merlin : bool -> unit
66756675

6676-
val walk_all_deps : string -> (string -> unit) -> unit
6676+
val walk_all_deps : bool -> string -> (bool -> string -> unit) -> unit
66776677
end = struct
66786678
#1 "bsb_default.ml"
66796679
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -6738,7 +6738,7 @@ let (|?) m (key, cb) =
67386738
TODO: check duplicate package name
67396739
?use path as identity?
67406740
*)
6741-
let rec walk_all_deps dir cb =
6741+
let rec walk_all_deps top dir cb =
67426742
let bsconfig_json = (dir // Literals.bsconfig_json) in
67436743
match Ext_json.parse_json_from_file bsconfig_json with
67446744
| `Obj map ->
@@ -6753,13 +6753,13 @@ let rec walk_all_deps dir cb =
67536753
begin match Bs_pkg.resolve_bs_package ~cwd:dir new_package with
67546754
| None -> failwith (new_package ^ " not found as dependency of " ^ bsconfig_json )
67556755
| Some package_dir ->
6756-
walk_all_deps package_dir cb ;
6756+
walk_all_deps false package_dir cb ;
67576757
end;
67586758
| _ -> () (* TODO: add a log framework, warning here *)
67596759
end
67606760
)))
67616761
|> ignore ;
6762-
cb dir
6762+
cb top dir
67636763
| _ -> ()
67646764
| exception _ -> failwith ( "failed to parse" ^ bsconfig_json ^ " properly")
67656765

@@ -7759,9 +7759,9 @@ type command =
77597759
*)
77607760
val run_commands : command list -> unit
77617761

7762-
val run_command_execv : command -> unit
7762+
val run_command_execv : bool -> command -> unit
77637763

7764-
val run_command_execvp : command -> unit
7764+
(* val run_command_execvp : command -> unit *)
77657765
end = struct
77667766
#1 "bsb_unix.ml"
77677767
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -7855,7 +7855,7 @@ let run_command_execvp cmd =
78557855
exit 2
78567856
end
78577857

7858-
let run_command_execv cmd =
7858+
let run_command_execv fail_exit cmd =
78597859
match Unix.fork () with
78607860
| 0 ->
78617861
print_endline ( "* Entering " ^ cmd.cwd);
@@ -7875,8 +7875,9 @@ let run_command_execv cmd =
78757875
if eid <> 0 then
78767876
begin
78777877
prerr_endline ("* Failure : " ^ cmd.cmd ^ "\n* Location: " ^ cmd.cwd);
7878-
exit eid
7879-
end
7878+
if fail_exit then exit eid
7879+
end;
7880+
78807881
| Unix.WSIGNALED _ | Unix.WSTOPPED _ ->
78817882
begin
78827883
prerr_endline (cmd.cmd ^ " interrupted");
@@ -8149,15 +8150,15 @@ let watch () =
81498150
let build_bs_deps () =
81508151
let bsc_dir = Bsb_build_util.get_bsc_dir cwd in
81518152
let bsb_exe = bsc_dir // "bsb.exe" in
8152-
Bsb_default.walk_all_deps cwd
8153-
(fun cwd -> Bsb_unix.run_command_execv
8153+
Bsb_default.walk_all_deps true cwd
8154+
(fun top cwd -> Bsb_unix.run_command_execv (not top)
81548155
{cmd = bsb_exe; cwd = cwd; args = [| bsb_exe |]})
81558156

81568157
let clean_bs_deps () =
81578158
let bsc_dir = Bsb_build_util.get_bsc_dir cwd in
81588159
let bsb_exe = bsc_dir // "bsb.exe" in
8159-
Bsb_default.walk_all_deps cwd
8160-
(fun cwd -> Bsb_unix.run_command_execv
8160+
Bsb_default.walk_all_deps true cwd
8161+
(fun top cwd -> Bsb_unix.run_command_execv (not top)
81618162
{cmd = bsb_exe; cwd = cwd; args = [| bsb_exe ; "--" ; "-t" ; "clean"|]})
81628163
let annoymous filename =
81638164
String_vec.push filename targets

jscomp/bsb/bsb_default.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let (|?) m (key, cb) =
6060
TODO: check duplicate package name
6161
?use path as identity?
6262
*)
63-
let rec walk_all_deps dir cb =
63+
let rec walk_all_deps top dir cb =
6464
let bsconfig_json = (dir // Literals.bsconfig_json) in
6565
match Ext_json.parse_json_from_file bsconfig_json with
6666
| `Obj map ->
@@ -75,13 +75,13 @@ let rec walk_all_deps dir cb =
7575
begin match Bs_pkg.resolve_bs_package ~cwd:dir new_package with
7676
| None -> failwith (new_package ^ " not found as dependency of " ^ bsconfig_json )
7777
| Some package_dir ->
78-
walk_all_deps package_dir cb ;
78+
walk_all_deps false package_dir cb ;
7979
end;
8080
| _ -> () (* TODO: add a log framework, warning here *)
8181
end
8282
)))
8383
|> ignore ;
84-
cb dir
84+
cb top dir
8585
| _ -> ()
8686
| exception _ -> failwith ( "failed to parse" ^ bsconfig_json ^ " properly")
8787

jscomp/bsb/bsb_default.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ val set_package_specs_from_array : Ext_json.t array -> unit
6565
val get_generate_merlin : unit -> bool
6666
val set_generate_merlin : bool -> unit
6767

68-
val walk_all_deps : string -> (string -> unit) -> unit
68+
val walk_all_deps : bool -> string -> (bool -> string -> unit) -> unit

jscomp/bsb/bsb_main.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,15 @@ let watch () =
252252
let build_bs_deps () =
253253
let bsc_dir = Bsb_build_util.get_bsc_dir cwd in
254254
let bsb_exe = bsc_dir // "bsb.exe" in
255-
Bsb_default.walk_all_deps cwd
256-
(fun cwd -> Bsb_unix.run_command_execv
255+
Bsb_default.walk_all_deps true cwd
256+
(fun top cwd -> Bsb_unix.run_command_execv (not top)
257257
{cmd = bsb_exe; cwd = cwd; args = [| bsb_exe |]})
258258

259259
let clean_bs_deps () =
260260
let bsc_dir = Bsb_build_util.get_bsc_dir cwd in
261261
let bsb_exe = bsc_dir // "bsb.exe" in
262-
Bsb_default.walk_all_deps cwd
263-
(fun cwd -> Bsb_unix.run_command_execv
262+
Bsb_default.walk_all_deps true cwd
263+
(fun top cwd -> Bsb_unix.run_command_execv (not top)
264264
{cmd = bsb_exe; cwd = cwd; args = [| bsb_exe ; "--" ; "-t" ; "clean"|]})
265265
let annoymous filename =
266266
String_vec.push filename targets

jscomp/bsb/bsb_unix.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ let run_command_execvp cmd =
8989
exit 2
9090
end
9191

92-
let run_command_execv cmd =
92+
let run_command_execv fail_exit cmd =
9393
match Unix.fork () with
9494
| 0 ->
9595
print_endline ( "* Entering " ^ cmd.cwd);
@@ -109,8 +109,9 @@ let run_command_execv cmd =
109109
if eid <> 0 then
110110
begin
111111
prerr_endline ("* Failure : " ^ cmd.cmd ^ "\n* Location: " ^ cmd.cwd);
112-
exit eid
113-
end
112+
if fail_exit then exit eid
113+
end;
114+
114115
| Unix.WSIGNALED _ | Unix.WSTOPPED _ ->
115116
begin
116117
prerr_endline (cmd.cmd ^ " interrupted");

jscomp/bsb/bsb_unix.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ type command =
3535
*)
3636
val run_commands : command list -> unit
3737

38-
val run_command_execv : command -> unit
38+
val run_command_execv : bool -> command -> unit
3939

40-
val run_command_execvp : command -> unit
40+
(* val run_command_execvp : command -> unit *)

0 commit comments

Comments
 (0)