Skip to content

Commit

Permalink
refactor: some cleanup and logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ulugbekna committed May 20, 2022
1 parent e5c9e8e commit 406e192
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 1 addition & 2 deletions src/opam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ end = struct
match file_res with
| Error e ->
log "Error reading switch-state file at %s. Error: %s"
switch_state_filepath
(Promise.error_to_js e |> Ojs.string_of_js);
switch_state_filepath (Node.JsError.message e);
None
| Ok file_content -> (
match
Expand Down
15 changes: 10 additions & 5 deletions src/treeview_switches.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ module Dependency = struct
let item = Vscode.TreeItem.make_label ~label ~collapsibleState () in
Vscode.TreeItem.set_iconPath item icon;
TreeItem.set_contextValue item (context_value dependency);
let+ _ =
let+ () =
Promise.Option.iter
(fun desc -> TreeItem.set_description item (`String desc))
(description dependency)
Expand All @@ -104,13 +104,18 @@ module Dependency = struct
Promise.return (Some names)
| Error err ->
show_message `Info
"An error occured while reading the switch dependencies: %s" err;
"An error occurred while reading the switch dependencies: %s" err;
Promise.return None)
| Package pkg -> (
let+ deps = Opam.Package.dependencies pkg in
match deps with
| Error _ -> None
| Ok packages -> Some (List.map ~f:(fun x -> Package x) packages))
| Ok packages -> Some (List.map ~f:(fun x -> Package x) packages)
| Error e ->
log
"An error occurred while getting package dependencies. Package %s. \
Error %s"
(Opam.Package.name pkg) e;
None)
end

module Command = struct
Expand Down Expand Up @@ -165,7 +170,7 @@ module Command = struct
match doc with
| None -> Promise.return ()
| Some doc ->
let+ _ =
let+ (_ : Ojs.t option) =
Vscode.Commands.executeCommand ~command:"vscode.open"
~args:[ Vscode.Uri.parse doc () |> Vscode.Uri.t_to_js ]
in
Expand Down

0 comments on commit 406e192

Please sign in to comment.