Skip to content

Commit

Permalink
Pull request #234: Bugfix/logging exceptions api errors
Browse files Browse the repository at this point in the history
Merge in EXC/orca-elements from bugfix/logging_exceptions_api_errors to master

* commit 'cae559d8b1ebb9d315f1c6e77c045c205576eb9d':
  Logging exceptions for API call errors
  • Loading branch information
Vrishab Srivatsa authored and prafulkoppalkar committed Sep 17, 2023
2 parents df14e7a + cae559d commit 115105e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 40 deletions.
39 changes: 9 additions & 30 deletions src/Utilities/PaymentHelpers.res
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,8 @@ let intentCall = (
resolve()
})
->catch(err => {
let exceptionJson =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.flatMap(OrcaUtils.safeParseOpt)
->Belt.Option.getWithDefault(Js.Json.null)
let exceptionJson = err->toJson

logApi(
~optLogger,
~url=uri,
Expand Down Expand Up @@ -357,12 +353,7 @@ let intentCall = (
let url = urlSearch(confirmParam.return_url)
url.searchParams.set(. "payment_intent_client_secret", clientSecret)
url.searchParams.set(. "status", "failed")
let exceptionJson =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.flatMap(OrcaUtils.safeParseOpt)
->Belt.Option.getWithDefault(Js.Json.null)
let exceptionJson = err->toJson
logApi(
~optLogger,
~url=uri,
Expand Down Expand Up @@ -672,12 +663,8 @@ let useSessions = (
json->resolve
})
->catch(err => {
let exceptionJson =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.flatMap(OrcaUtils.safeParseOpt)
->Belt.Option.getWithDefault(Js.Json.null)
let exceptionJson = err->toJson

logApi(
~optLogger,
~url=uri,
Expand Down Expand Up @@ -746,12 +733,8 @@ let usePaymentMethodList = (~clientSecret, ~publishableKey, ~logger) => {
json->resolve
})
->catch(err => {
let exceptionJson =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.flatMap(OrcaUtils.safeParseOpt)
->Belt.Option.getWithDefault(Js.Json.null)
let exceptionJson = err->toJson

logApi(
~optLogger=Some(logger),
~url=uri,
Expand Down Expand Up @@ -817,12 +800,8 @@ let useCustomerDetails = (~clientSecret, ~publishableKey, ~optLogger) => {
})
->then(res => resolve(res))
->catch(err => {
let exceptionJson =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.flatMap(OrcaUtils.safeParseOpt)
->Belt.Option.getWithDefault(Js.Json.null)
let exceptionJson = err->toJson

logApi(
~optLogger,
~url=uri,
Expand Down
13 changes: 3 additions & 10 deletions src/orca-loader/Elements.res
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,7 @@ let make = (
resolve()
})
->catch(err => {
let exceptionMessage =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.getWithDefault("TrustPay GooglePay Error")
let exceptionMessage = err->toJson->Js.Json.stringify
logger.setLogInfo(
~value=exceptionMessage,
~eventName=GOOGLE_PAY_FLOW,
Expand Down Expand Up @@ -522,11 +518,8 @@ let make = (
resolve()
})
->catch(err => {
let exceptionMessage =
err
->Js.Exn.asJsExn
->Belt.Option.flatMap(Js.Exn.message)
->Belt.Option.getWithDefault("TrustPay ApplePay Error")
let exceptionMessage = err->toJson->Js.Json.stringify

logger.setLogInfo(
~eventName=APPLE_PAY_FLOW,
~paymentMethod="APPLE_PAY",
Expand Down

0 comments on commit 115105e

Please sign in to comment.