Skip to content

Commit 237df92

Browse files
ArturWieczorekkderme
authored andcommitted
Fix: Remove "Just" prefix in error messages for OffChainFetchError
- Updated the `Show` instance for `OffChainFetchError` to use a custom function that properly formats `Maybe OffChainUrlType` values. - Added `showMaybeUrl` helper function to convert `Maybe OffChainUrlType` to string without including "Just". - Remove redundant single quote from connection failure string.
1 parent b0f0134 commit 237df92

File tree

1 file changed

+10
-5
lines changed
  • cardano-db-sync/src/Cardano/DbSync

1 file changed

+10
-5
lines changed

cardano-db-sync/src/Cardano/DbSync/Types.hs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ instance Show OffChainFetchError where
241241
OCFErrHashMismatch url xpt act ->
242242
mconcat
243243
[ "Hash mismatch when fetching metadata from "
244-
, show url
244+
, showMUrl url
245245
, ". Expected "
246246
, show xpt
247247
, " but got "
@@ -256,7 +256,7 @@ instance Show OffChainFetchError where
256256
[fetchUrlToString url, "URL parse error for ", show url, " resulted in : ", show err]
257257
OCFErrJsonDecodeFail url err ->
258258
mconcat
259-
[fetchMUtlToString url, "JSON decode error from when fetching metadata from ", show url, " resulted in : ", show err]
259+
[fetchMUrlToString url, "JSON decode error from when fetching metadata from ", show url, " resulted in : ", show err]
260260
OCFErrHttpException url err ->
261261
mconcat [fetchUrlToString url, "HTTP Exception error for ", show url, " resulted in : ", show err]
262262
OCFErrHttpResponse url sc msg ->
@@ -269,11 +269,16 @@ instance Show OffChainFetchError where
269269
mconcat [fetchUrlToString url, "Timeout error when fetching metadata from ", show url, ": ", show ctx]
270270
OCFErrConnectionFailure url ->
271271
mconcat
272-
[fetchUrlToString url, "Connection failure error when fetching metadata from ", show url, "'."]
272+
[fetchUrlToString url, "Connection failure error when fetching metadata from ", show url, "."]
273273
OCFErrIOException err -> "IO Exception: " <> show err
274274

275-
fetchMUtlToString :: Maybe OffChainUrlType -> String
276-
fetchMUtlToString = \case
275+
showMUrl :: Maybe OffChainUrlType -> String
276+
showMUrl = \case
277+
Nothing -> "unknown URL"
278+
Just url -> show url
279+
280+
fetchMUrlToString :: Maybe OffChainUrlType -> String
281+
fetchMUrlToString = \case
277282
Nothing -> ""
278283
Just url -> fetchUrlToString url
279284

0 commit comments

Comments
 (0)