Skip to content

Commit

Permalink
log at start of send_notification before potential errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yasunariw committed Jan 4, 2021
1 parent 9bd0cae commit 6e18496
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/api_remote.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ module Slack : Api.Slack = struct
(** `send_notification ctx msg` notifies `msg.channel` with the payload `msg`;
uses web API with access token if available, or with webhook otherwise *)
let send_notification ~(ctx : Context.t) ~(msg : Slack_t.post_message_req) =
log#info "sending to %s" msg.channel;
let build_error e = fmt_error "%s\nfailed to send Slack notification" e in
let build_query_error url e = build_error @@ sprintf "error while querying %s: %s" url e in
let secrets = Context.get_secrets_exn ctx in
Expand All @@ -68,7 +69,7 @@ module Slack : Api.Slack = struct
| Some url ->
let data = Slack_j.string_of_post_message_req msg in
let body = `Raw ("application/json", data) in
log#info "sending to %s : %s" msg.channel data;
log#info "data: %s" data;
( match%lwt http_request ~body ~headers `POST url with
(* error detection in response: slack uses status codes for webhooks versus a 200 code w/ `error` field for web api *)
| Ok s ->
Expand Down

0 comments on commit 6e18496

Please sign in to comment.