Skip to content

Commit 993e286

Browse files
committed
Improve web-worker debug messages
1 parent 3641979 commit 993e286

3 files changed

+11
-11
lines changed

learn-ocaml-client.opam.locked

-3
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ depends: [
6565
"gg" {= "1.0.0"}
6666
"gmap" {= "0.3.0"}
6767
"hex" {= "1.4.0"}
68-
"host-arch-x86_64" {= "1"}
69-
"host-system-other" {= "1"}
7068
"ipaddr" {= "5.6.0"}
7169
"ipaddr-sexp" {= "5.6.0"}
7270
"jane-street-headers" {= "v0.16.0"}
@@ -90,7 +88,6 @@ depends: [
9088
"mirage-crypto-rng" {= "0.11.3"}
9189
"num" {= "1.4"}
9290
"ocaml" {= "5.0.0"}
93-
"ocaml-base-compiler" {= "5.0.0"}
9491
"ocaml-compiler-libs" {= "v0.12.4"}
9592
"ocaml-config" {= "3"}
9693
"ocaml-options-vanilla" {= "1"}

learn-ocaml.opam.locked

-3
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ depends: [
6767
"gg" {= "1.0.0"}
6868
"gmap" {= "0.3.0"}
6969
"hex" {= "1.4.0"}
70-
"host-arch-x86_64" {= "1"}
71-
"host-system-other" {= "1"}
7270
"ipaddr" {= "5.6.0"}
7371
"ipaddr-sexp" {= "5.6.0"}
7472
"jane-street-headers" {= "v0.16.0"}
@@ -100,7 +98,6 @@ depends: [
10098
"mirage-crypto-rng" {= "0.11.3"}
10199
"num" {= "1.4"}
102100
"ocaml" {= "5.0.0"}
103-
"ocaml-base-compiler" {= "5.0.0"}
104101
"ocaml-compiler-libs" {= "v0.12.4"}
105102
"ocaml-config" {= "3"}
106103
"ocaml-options-vanilla" {= "1"}

src/toplevel/learnocaml_toplevel_worker_main.ml

+11-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ let is_success = function
1717
| Toploop_ext.Ok _ -> true
1818
| Toploop_ext.Error _ -> false
1919

20+
let success_string = function
21+
| Toploop_ext.Ok _ -> "OK"
22+
| Toploop_ext.Error (((_, e),_),_) -> "Error: "^e
23+
2024
type 'a return =
2125
| ReturnSuccess of 'a * Toploop_ext.warning list
2226
| ReturnError of Toploop_ext.error * Toploop_ext.warning list
@@ -166,7 +170,8 @@ let handler : type a. a host_msg -> a return Lwt.t = function
166170
let ppf_answer = make_answer_ppf fd_answer in
167171
if !debug then Js_utils.debug "Worker: -> Execute (%S)" code;
168172
let result = Toploop_ext.execute ?ppf_code ~print_outcome ~ppf_answer code in
169-
if !debug then Js_utils.debug "Worker: <- Execute (%B)" (is_success result);
173+
if !debug then
174+
Js_utils.debug "Worker: <- Execute (%s)" (success_string result);
170175
iter_option close_fd fd_code;
171176
close_fd fd_answer;
172177
unwrap_result result
@@ -178,10 +183,11 @@ let handler : type a. a host_msg -> a return Lwt.t = function
178183
try Toploop_jsoo.use_compiled_string js_code; Toploop_ext.Ok (true, [])
179184
with exn ->
180185
Firebug.console##log (Js.string (Printexc.to_string exn));
181-
Format.fprintf ppf_answer "%s" (Printexc.to_string exn); Toploop_ext.Ok (false, [])
186+
Format.fprintf ppf_answer "%s" (Printexc.to_string exn);
187+
Toploop_ext.Ok (false, [])
182188
in
183189
if !debug then
184-
Js_utils.debug "Worker: <- Use_js_string (%B)" (is_success result);
190+
Js_utils.debug "Worker: <- Use_js_string (%s)" (success_string result);
185191
close_fd fd_answer;
186192
unwrap_result result
187193
| Use_string (filename, print_outcome, fd_answer, code) ->
@@ -190,7 +196,7 @@ let handler : type a. a host_msg -> a return Lwt.t = function
190196
Js_utils.debug "Worker: -> Use_string (%S)" code;
191197
let result = Toploop_ext.use_string ?filename ~print_outcome ~ppf_answer code in
192198
if !debug then
193-
Js_utils.debug "Worker: <- Use_string (%B)" (is_success result);
199+
Js_utils.debug "Worker: <- Use_string (%s)" (success_string result);
194200
close_fd fd_answer;
195201
unwrap_result result
196202
| Use_mod_string (fd_answer, print_outcome, modname, sig_code, impl_code) ->
@@ -202,7 +208,7 @@ let handler : type a. a host_msg -> a return Lwt.t = function
202208
~ppf_answer ~print_outcome ~modname ?sig_code impl_code in
203209
if !debug then
204210
Js_utils.debug
205-
"Worker: <- Use_mod_string %s (%B)" modname (is_success result);
211+
"Worker: <- Use_mod_string %s (%s)" modname (success_string result);
206212
close_fd fd_answer;
207213
unwrap_result result
208214
| Set_debug b ->

0 commit comments

Comments
 (0)