Commits

Stephen Weeks  committed 41a5ec1

fixed bug in [send], so that it writes the error to the log

  • Participants
  • Parent commits 1b6d56a

Comments (0)

Files changed (2)

   (let* ((dir (locate-dominating-file path "OMakeroot"))
          ;; locate-dominating-file leaves the last slash on the path
          (dir (Filename.strip-final-slash dir)))
-    (if (not dir) (error "Can't determine omakeroot-dir from %s" path))
+    (if (not dir)
+        (error "Can't determine OMake project: no OMakeroot in %s or any of its ancestors"
+               path))
     (assert (file-directory-p dir))
     dir))
 ;; (Omake.Path.omakeroot-dir "/mnt/local/sda1/smclaughlin/elisp/dev/omake-mode")

File omake_server.ml

-
 open Core.Std
 open Async.Std
 
 let ( ** ) f g x = f (g x)
 let dprintf fmt = Printf.printf (fmt ^^ "\n%!")
 let exn_to_string exn = Exn.to_string (Monitor.extract_exn exn)
+(* CR sweeks: Disabling [Exn] is perverse. *)
 module Exn = struct end
 
 (* -------------------------------------------------------------------------- *)
   let logf fmt =
     match Deferred.peek (Lazy.force log_writer) with
     | None ->
-      printf "WARNING: no log writer.  Writing to stdout.\n";
-      ksprintf (fun s -> printf "%s" (log_msg s)) fmt
+      eprintf "WARNING: no log writer.  Writing to stderr.\n";
+      ksprintf (fun s -> eprintf "%s" (log_msg s)) fmt
     | Some writer ->
       ksprintf (fun s -> Writer.writef writer "%s" (log_msg s)) fmt
   let log_exn ?(msg = "Caught exception") e =
     )
     (fun msg ->
       schedule
-      ~f:(fun () ->
-        try_with (fun () -> connect msg) >>| function
-        | Error exn ->
-          Server.log_exn (Monitor.extract_exn exn);
-          To_emacs.send_async "(message \"Omake server error.  Do M-x Omake.show-server-log\")"
-        | Ok () -> ())
-      ~quit:()
-      ())
+        ~f:(fun () ->
+          Server.wait_for_log ()
+          >>= fun () ->
+          try_with (fun () -> connect msg)
+          >>| function
+          | Ok () -> ()
+          | Error exn ->
+            Server.log_exn exn;
+            To_emacs.send_async "(message \"Omake server error.  Do M-x Omake.show-server-log\")")
+        ~quit:()
+        ())
+;;
 
 let in_use_cmd =
   Command.basic