Skip to content

Commit

Permalink
[enhance] compiler: Prettier js parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
BourgerieQuentin committed Aug 7, 2012
1 parent bcbeb3e commit 8abdc7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 7 additions & 2 deletions compiler/jslang/globalizer.ml
@@ -1,5 +1,5 @@
(*
Copyright © 2011 MLstate
Copyright © 2011, 2012 MLstate
This file is part of Opa.
Expand Down Expand Up @@ -78,7 +78,12 @@ let _ =
try
JsParse.String.code ~throw_exn:true content
with
_ -> die "Could not read input"
JsParse.Exception e ->
OManager.error
("Couldn't parse file @{<brigth>%s@}\n"^^
"Error : %a")
filename
JsParse.pp e
in
(filename, JsUtils.export_to_global_namespace content)
) files
Expand Down
9 changes: 8 additions & 1 deletion compiler/libbsl/bslRegisterLib.ml
Expand Up @@ -992,7 +992,14 @@ let export_to_global_namespace nodejs_code =
try
JsParse.String.code ~throw_exn:true contents
with
_ -> OManager.error "Couldn't parse file %s\n" filename
JsParse.Exception e ->
ignore (File.output "jserror.js" contents);
OManager.error
("Couldn't parse file @{<brigth>%s@} after preprocessing\n"^^
"Take a look on generated file @{<brigth>jserror.js@}\n%!" ^^
"Error : %a")
filename
JsParse.pp e
in
let contents = JsUtils.export_to_global_namespace contents in
(filename, Format.to_string JsPrint.pp_min#code contents, conf)
Expand Down

0 comments on commit 8abdc7d

Please sign in to comment.