From 692ddd94dec4dd4a3e90e2b41ffe40884ec452ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Zimmermann?= Date: Mon, 22 May 2023 12:23:01 +0200 Subject: [PATCH] Do not lose error message when createCheckRun query fails. --- bot-components/GitHub_mutations.ml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bot-components/GitHub_mutations.ml b/bot-components/GitHub_mutations.ml index 7c2bb6ef..74ab2c12 100644 --- a/bot-components/GitHub_mutations.ml +++ b/bot-components/GitHub_mutations.ml @@ -157,6 +157,7 @@ let create_check_run ~bot_info ?conclusion ~name ~repo_id ~head_sha ~status }\n\n\ }\n" in + let open Lwt_result.Infix in makeVariables ~name ~repoId:(GitHub_ID.to_string repo_id) ~headSha:head_sha ~status ~title ?text ~summary ~url:details_url ?conclusion @@ -164,11 +165,11 @@ let create_check_run ~bot_info ?conclusion ~name ~repo_id ~head_sha ~status |> serializeVariables |> variablesToJson |> send_graphql_query ~bot_info ~query ~parse:(Fn.compose parse unsafe_fromJson) - >|= Result.bind ~f:(function - | {createCheckRun= Some {checkRun= Some {url}}} -> - Ok url - | _ -> - Error (f "Warning: Could not retrieve new check run URL.") ) + >>= function + | {createCheckRun= Some {checkRun= Some {url}}} -> + Lwt_result.return url + | _ -> + Lwt_result.fail (f "No new check run URL provided in GitHub answer.") let update_check_run ~bot_info ~check_run_id ~repo_id ~conclusion ?details_url ~title ?text ~summary () =