From 9224829b46b350feece670ec26920f9ba9128624 Mon Sep 17 00:00:00 2001 From: Greg Hale Date: Mon, 11 Sep 2023 12:46:27 -0700 Subject: [PATCH] Fix error message behavior for base64 native --- src/Pact/Native.hs | 4 +++- tests/pact/base64.repl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Pact/Native.hs b/src/Pact/Native.hs index b72229432..720b9aa06 100644 --- a/src/Pact/Native.hs +++ b/src/Pact/Native.hs @@ -1415,7 +1415,9 @@ base64decode = defRNative "base64-decode" go -- Use Legacy error behavior when 4.9 is disabled. base64Behavior <- bool Simplified Legacy <$> isExecutionFlagSet FlagDisablePact49 parseResult <- base64DecodeWithShimmedErrors (getInfo i) base64Behavior s - case parseResult of + let + parseResultErrorContext = first ("Could not decode string: " <>) $ parseResult + case parseResultErrorContext of Right bs -> case T.decodeUtf8' bs of Right t -> return $ tStr t Left _unicodeError -> evalError' i $ "invalid unicode" diff --git a/tests/pact/base64.repl b/tests/pact/base64.repl index 30c8fbaa5..39b834e75 100644 --- a/tests/pact/base64.repl +++ b/tests/pact/base64.repl @@ -24,7 +24,7 @@ (expect-failure "base64 decoding fails on non base64-encoded input" - "invalid padding near offset 16" + "Could not decode string" (base64-decode "aGVsbG8gd29ybGQh%")) (expect-failure