bring back Linol_eio.spawn for logging uncaught exceptions

This commit is contained in:
kuviman 2025-12-02 00:33:17 +04:00
parent 40843b81db
commit 705cc47ddf
2 changed files with 11 additions and 1 deletions

View file

@ -45,7 +45,7 @@ class lsp_server ~(sw: Eio.Switch.t) =
val buffers : (Lsp.Types.DocumentUri.t, state_after_processing) Hashtbl.t = val buffers : (Lsp.Types.DocumentUri.t, state_after_processing) Hashtbl.t =
Hashtbl.create 32 Hashtbl.create 32
method spawn_query_handler f = Eio.Fiber.fork ~sw f method spawn_query_handler f = Linol_eio.spawn ~sw f
(* We define here a helper method that will: (* We define here a helper method that will:
- process a document - process a document

View file

@ -51,6 +51,16 @@ module IO_eio :
let read_line in_ch = Eio.Buf_read.line in_ch let read_line in_ch = Eio.Buf_read.line in_ch
end end
(** Spawn function. *)
let spawn ~sw f =
Eio.Fiber.fork ~sw (fun () ->
try
f ()
with exn ->
Printf.eprintf "uncaught exception in `spawn`:\n%s\n%!"
(Printexc.to_string exn);
raise exn)
include Lsp.Types include Lsp.Types
include IO_eio include IO_eio